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

Fix error when allOf two refs #335

Merged
merged 2 commits into from
Nov 9, 2022

Conversation

xvladqt
Copy link
Contributor

@xvladqt xvladqt commented Nov 9, 2022

Description

Add x-examples resolver for json-schema-merge-allof

Motivation and Context

Generate throw error:

WARNING: failed to create example from schema object: Error: No resolver found for key x-examples. You can provide a resolver for this keyword in the options, or provide a default resolver.
[ERROR] Error: No resolver found for key x-examples. You can provide a resolver for this keyword in the options, or provide a default resolver.

in this case

Test:
  description: Test
  allOf:
    - $ref: '#/components/schemas/TestA'
    - $ref: '#/components/schemas/TestB'
  x-examples:
    Example:
      value:
        test1: false
        test2: false

TestA:
  type: object
  description: testA
  properties:
    test1:
      type: boolean
      example: false
  required:
    - test1
  x-examples:
    Example:
      value:
        test1: true

TestB:
  type: object
  description: TestB
  properties:
    test2:
      type: boolean
      example: false
  required:
    - test2
  x-examples:
    Example:
      value:
        test2: true

How Has This Been Tested?

  1. yarn test - success
  2. Generate for my specification, which throw error before that

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

@welcome-to-palo-alto-networks
Copy link

🎉 Thanks for opening this pull request! We really appreciate contributors like you! 🙌

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

Visit the preview URL for this PR (updated for commit 43bac65):

https://docusaurus-openapi-36b86--pr335-7ro33da0.web.app

(expires Fri, 09 Dec 2022 20:46:16 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link
Member

@sserrata sserrata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @xvladqt. Does it make sense to also add support for x-example (singular)? Perhaps not single x-example could only be a single example?

@xvladqt
Copy link
Contributor Author

xvladqt commented Nov 9, 2022

@sserrata if x-example without allOf all good, this problem exists only if allOf with 2+ refs and x-example. If I understand the question correctly.

@sserrata
Copy link
Member

sserrata commented Nov 9, 2022

@sserrata if x-example without allOf all good, this problem exists only if allOf with 2+ refs and x-example. If I understand the question correctly.

Thanks @xvladqt that makes sense.

Copy link
Member

@sserrata sserrata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix linter errors. You may try running yarn run format. If that doesn't work, try running the format script manually, i.e. prettier . --check --ignore-unknown --ignore-path .prettierignore.

I know that sometimes the globally installed prettier can interfere so you might need to specify you want to run the prettier installed locally, e.g. ./node_modules/.bin/prettier.

@xvladqt
Copy link
Contributor Author

xvladqt commented Nov 9, 2022

@sserrata I forget about prettier, fixed it now

@sserrata sserrata merged commit 0fd44b5 into PaloAltoNetworks:main Nov 9, 2022
@welcome-to-palo-alto-networks
Copy link

🎉 Congrats on getting your first pull request merged! We here at Palo Alto Networks are so grateful! ❤️

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

Successfully merging this pull request may close these issues.

None yet

2 participants