question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Order of resolution of references - resolve remotes first?

See original GitHub issue

Issue Description

Given this folder structure:

|   index.yaml
|   parameters.yaml
|   responses.yaml
|   
+---definitions
|   |   index.yaml
|   |   
|   +---error
|   |       error_model.yaml
|   |       extended_error_model.yaml
|               
\---paths
    |   index.yaml

Consider this yaml:

index.yaml

swagger: '2.0'

info:
  version: 1.0.0
  title: User API
  description: User specific API

schemes:
  - http
  - https

produces:
  - application/json
  - text/json

paths:
  $ref: ./paths/index.yaml

definitions:
  $ref: ./definitions/index.yaml

parameters:
  $ref: ./parameters.yaml

responses:
  $ref: ./responses.yaml

responses.yaml

# Common responses
200:
  description: OK
  schema:
    type: string

DefaultError:
  description: Error payload
  schema:
    $ref: '#/definitions/ExtendedErrorModel'

extended_error_model.yaml

allOf:
- $ref: '#/definitions/ErrorModel'
- type: object
  properties:
    detail:
      type: string
    meta:
      type: string

error_model.yaml

type: object
required:
  - status
  - code
  - title
properties:
  code:
    type: integer
  title:
    type: string
  status:
    type: integer
    minimum: 100
    maximum: 600

SwaggerParser.validate('index.yaml') fails because '#/definitions/ExtendedErrorModel' doesn’t exist inside responses.yaml. However, if I use json-refs and js-yaml to load and parse the YAML, the resolution works.

I believe this is because json-refs first resolves all remote refs, then proceeds with local ones.

I’m not sure if the spec (OAI or json ref) dictates one way or the other. So I’m not sure if this is an issue or not.

Could you please shed some light on this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
whitlockjccommented, Oct 6, 2016

No problem. The good news is this feature was a pain to implement anyways so removing it makes my life easier. 👍

0reactions
JamesMessingercommented, Oct 19, 2016

Closing this issue, since Swagger Parser is working as intended.

Read more comments on GitHub >

github_iconTop Results From Across the Web

git pull fails "unable to resolve reference" "unable to update ...
These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>". Share.
Read more >
Module Resolution
A resolver is a library which helps in locating a module by its absolute path. A module can be required as a dependency...
Read more >
community/0060-remote-resource-resolution.md at main
Resource Resolution : The act of taking a reference to a Tekton resource in a Remote, fetching it, and returning its content to...
Read more >
p4 resolve
Resolution of a file is completed when any of the accept dialog options are chosen. To resolve the file later or to revert...
Read more >
How to resolve: git push remote: error: cannot lock ref .. ...
Solved: I'm struggling to solve an issues with one of my repositories. It started with a failed push from sourcetree, on attempting to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found