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: $ref in allOf in query/headers causes Fastify to crash #609

Merged
merged 6 commits into from
Jun 10, 2022

Conversation

HiiiiD
Copy link
Contributor

@HiiiiD HiiiiD commented Jun 7, 2022

Fixes #604.

Checklist

@mcollina
Copy link
Member

mcollina commented Jun 7, 2022

Can you please rebase? I've fixed the tests.

@HiiiiD HiiiiD marked this pull request as draft June 7, 2022 15:44
@HiiiiD
Copy link
Contributor Author

HiiiiD commented Jun 7, 2022

I've converted it back to draft because I've found an issue with headers.
If you don't provide a description to headers in a allOf then Swagger.validate() will throw this exception:

Data does not match any schemas from 'oneOf' at #/paths//url1/get/parameters/1
    Expected type string but found type undefined at #/paths//url1/get/parameters/1/description     Missing required
  property: $ref at #/paths//url1/get/parameters/1   Data does not match any schemas from 'oneOf' at
  #/paths//url1/get/parameters/0     Expected type string but found type undefined at
  #/paths//url1/get/parameters/0/description     Missing required property: $ref at #/paths//url1/get/parameters/0
  JSON_OBJECT_VALIDATION_FAILED

@HiiiiD
Copy link
Contributor Author

HiiiiD commented Jun 9, 2022

I think that I've found the issue.
It seems that swagger-parser@10.0.3 always wants a description in the headers.
Updating to @apidevtools/swagger-parser@10.1.0 fixes the issue but it sets description as undefined

@HiiiiD HiiiiD marked this pull request as ready for review June 9, 2022 17:16
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

Although, I think it should be something fixed inside json-schema-resolver.
I accept it as a solution for this problem.

@mcollina mcollina merged commit 9b6cd9e into fastify:master Jun 10, 2022
@HiiiiD HiiiiD mentioned this pull request Jun 12, 2022
4 tasks
Eomm pushed a commit that referenced this pull request Nov 3, 2022
* fix: $ref in allOf in query/headers causes Fastify to crash

* Use the same split for $ref
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.

$ref in allOf in query/headers causes Fastify to crash
3 participants