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

YAML merge keys are identified as as Invalid Key errors #87

Closed
jamiethompson opened this issue May 8, 2017 · 12 comments
Closed

YAML merge keys are identified as as Invalid Key errors #87

jamiethompson opened this issue May 8, 2017 · 12 comments

Comments

@jamiethompson
Copy link

When using YAML merge keys to merge in aliases, the merge keys are identified as errors 'Invalid key'

Example YAML

responses:
  <<: *default_response
  201:
    description: Created
    schema:
      $ref: '#/definitions/ProductVariation'
@jamiethompson jamiethompson changed the title YAML merge keys are highlighted as errors YAML merge keys are identified as as Invalid Key errors May 8, 2017
@semonte
Copy link
Contributor

semonte commented May 9, 2017

Hi @jamiethompson

Thanks for reporting this, needs to be fixed.

@jamiethompson
Copy link
Author

No problem. I have also just this morning noticed that using merge keys also appears to break the Swagger UI generation.

@semonte
Copy link
Contributor

semonte commented May 23, 2017

@jamiethompson are you able to share the Swagger file a bit more? How does the default_response element look like?

I want to create proper tests for the merge keys, this would be valuable test data.

@jamiethompson
Copy link
Author

No problem, here's what the &default_response anchor looks like

responses:
    Default: &default_response
      # Errors
      400:
        $ref: '#/responses/400BadRequest'
      401:
        $ref: '#/responses/401Unauthorized'
      403:
        $ref: '#/responses/403Forbidden'
      404:
        $ref: '#/responses/404NotFound'
      409:
        $ref: '#/responses/409Conflict'
      429:
        $ref: '#/responses/429TooManyRequests'
      500:
        $ref: '#/responses/500InternalServerError'
      503:
        $ref: '#/responses/503ServiceUnavailable'

Let me know if you need anything more

semonte pushed a commit that referenced this issue May 24, 2017
Exclude YAML merge and anchor keys when validating Swagger keys.

Fixes #87
semonte pushed a commit that referenced this issue May 24, 2017
Exclude YAML merge and anchor keys when validating Swagger keys.

Fixes #87
@semonte
Copy link
Contributor

semonte commented May 24, 2017

No problem. I have also just this morning noticed that using merge keys also appears to break the Swagger UI generation.

Unfortunately Jackson does not support transforming YAML to JSON with merge keys and anchors (we use Jackson to transform YAML to JSON for Swagger UI).

@semonte
Copy link
Contributor

semonte commented May 24, 2017

Thanks for the example spec, this is fixed now. I still need to make a release, should happen by the end of next week.

@jamiethompson
Copy link
Author

No problem. I look forward to the release 😄

@semonte
Copy link
Contributor

semonte commented May 26, 2017

FYI: I made a PR for JetBrains about anchors and aliases in YAML files. In the future we can hopefully jump to declaration by clicking an alias :) JetBrains/intellij-community#577

@jamiethompson
Copy link
Author

Wow, thanks. That would make writing large specs so much easier.

@semonte
Copy link
Contributor

semonte commented Jun 7, 2017

@jamiethompson The plugin has been updated, you should no longer see the errors.

@jamiethompson
Copy link
Author

Thank you. Updated today. Works a treat.

@naufq
Copy link

naufq commented Jul 26, 2021

No problem. I have also just this morning noticed that using merge keys also appears to break the Swagger UI generation.

Unfortunately Jackson does not support transforming YAML to JSON with merge keys and anchors (we use Jackson to transform YAML to JSON for Swagger UI).

Does Swagger UI still suffer from this issue?

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

No branches or pull requests

3 participants