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

Wiretap shows violations when response object has string as null when the open API specifies nullable: true #97

Open
mdiwakar opened this issue Feb 8, 2024 · 7 comments

Comments

@mdiwakar
Copy link

mdiwakar commented Feb 8, 2024

145 | /allOf/1/properties/results/items/allOf/1/properties/speakerId/type | expected string, but got null -- | -- | --
  1.                         type: string
    
  2.                         nullable: true
    

Specification:

      properties:
        speakerId:
          nullable: true
          type: string

nullable true is not handled correctly.

@LasneF
Copy link

LasneF commented Feb 16, 2024

what was the version of the OAS spec ?
because in recent version nullable : true is not supported , null beeing a definitive type

so sould be type : [string , null ]

more details here
https://stackoverflow.com/questions/48111459/how-to-define-a-property-that-can-be-string-or-null-in-openapi-swagger#:~:text=OAS2%20does%20not%20support%20%27null%27%20as%20the%20data,are%20not%20part%20of%20the%20OpenAPI%202.0%20Specification.

@mdiwakar
Copy link
Author

the version is version: 3.0.0

@mdiwakar
Copy link
Author

mdiwakar commented May 9, 2024

any further updates on this issue?

@daveshanley
Copy link
Member

The problem here is that this schema validation is performed by a dependency, not wiretap, it's being handled by github.com/santhosh-tekuri/jsonschema/v5

Code is here: https://github.com/pb33f/libopenapi-validator/blob/main/schema_validation/validate_schema.go#L126

@LasneF
Copy link

LasneF commented May 13, 2024

should a ticket been raised ?

@collin-rogers
Copy link

Any update on supporting this? This blocks me from being able to adopt this tool. It looks like the dependency that is to blame is on v6.

@LasneF
Copy link

LasneF commented Sep 16, 2024

@daveshanley nullable is a mess introduced in 3.0 and removed in 3.1.0

the upgrade to the newest version https://github.com/santhosh-tekuri/jsonschema/releases/tag/v6.0.0

will not help as it is not related to json schema but to OAS directly

@mdiwakar i would advise you to upgrade to OAS 3.1 if you can, otherwise the fix is a oneOf only for version 3.0
here any contribution will be welcome

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

4 participants