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

how to combine $ref and default? #469

Open
maxlapshin opened this issue Sep 14, 2021 · 1 comment
Open

how to combine $ref and default? #469

maxlapshin opened this issue Sep 14, 2021 · 1 comment

Comments

@maxlapshin
Copy link

Field in API can refer to some component and have default value. Speccy doesn't allow combining allOf $ref and default

Detailed description

For example:

components:
    frame_video_pix_fmt:
      enum:
        - yuv420p
        - yuvj420p
        - yuv422p
        - yuv444p
...

        pix_fmt:
          allOf:
            - $ref: "#/components/schemas/frame_video_pix_fmt"
          default: yuv420p

It is illegal to specify

        pix_fmt:
          $ref: "#/components/schemas/frame_video_pix_fmt"
          default: yuv420p

because $ref must rewrite completely current object and does not allow any siblings.
Using allOf is a working hack to allow having siblings for $ref, but speccy doesn't allow default with $ref

I suppose that speccy should either validate default against referenced component, either do not complain about having default without type:

$ speccy lint   http://localhost:8080/flussonic/api/v3/schema
Specification schema is invalid.

#/components/schemas/track_info/properties/pix_fmt
expected Object {
  allOf: Array [ Object { $ref: '#/components/schemas/frame_video_pix_fmt' } ],
  default: 'yuv420p',
  deprecated: true
} to have property type

Your environment

$ speccy --version
0.11.0
$ node --version
v14.7.0
$ uname -a
Darwin maxbook-m1.e 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64
@maxlapshin
Copy link
Author

Please, consider updating dependency from oas-kit:

https://github.com/Mermade/oas-kit/blob/main/packages/oas-validator/index.js#L220

It has laxDefault option now that allows to pass mismatch between default and type options

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

1 participant