Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output file generation issue: Merging of $refs for error response definitions not working as expected #379

Open
jcfausto opened this issue Dec 19, 2019 · 3 comments

Comments

@jcfausto
Copy link

$refs are not being rendered correctly when generating the output file. It looks like a bug.

Detailed description

Descriptions below are based on this example: https://github.com/jcfausto/speccy-ref-path-rendering-issue

Command used to output the file:

$ npx speccy resolve -v index.yaml -o output.yaml

Expected outcome

That every $ref will have its content rendered to the output.yaml file.

Details

├── README.md
├── index.yaml
├── output.yaml
├── shared
│   └── schemas
│       └── error.yaml
└── v1
    ├── books
    │   └── index.yaml
    └── pets
        └── index.yaml

I have a single definition for error messages in the shared/schemas/error.yaml file.

For the resources books and pets I'd like to reuse that when describing error responses as you can see in /v1/books/index.yaml and /v1/pets/index.yaml files.

When I render the output file, the first occurence of the $ref to the shared/schemas/error.yaml is merged correctly, but the following references don't.

They get merged, for all other reference toshared/schemas/error.yaml like this:

$ref: "#/paths/~1v1~1books/get/responses/401/content/application~1json/schema"

The base path #/paths/~1v1~1books, method get and status code 401 are all comming from the first $ref that was rendered correctly.

That creates outputs like this:

  /v1/pets:
    get:
      responses:
        "200":
          description: success
        "500":
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: "#/paths/~1v1~1books/get/responses/401/content/application~1j\
                  son/schema"

Where, the path is /v1/pets, but the $ref for the 500 status code is referencing the /v1/books path and the 401 status code when it should have merged the content of the referenced file instead.

Your environment

Node: 10.18.0
Speccy: 0.11.0

@sashasklar
Copy link

Is there any update on this issue? I'm facing the same issue where imported schemas show up as paths

@jcfausto
Copy link
Author

jcfausto commented May 9, 2020

No progress so far. Won't be able to work on this issue any soon. If you're using Redoc as well, you might want to look at the bundle command. In our case, it was a good replacement.

@quintus-luis
Copy link

Same problem here....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants