-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add nullable
attribute
#71
Comments
I am facing this issue as well. data Foo = Foo
{ optionalNotNullable :: Maybe String
, optionalNullable :: Maybe String
, requiredNullable :: Maybe String
, requiredNotNullable :: String
} Which should have a schema looking like this: {
"properties": {
"optionalNotNullable": { "type": "string" },
"optionalNullable": { "type": "string", "nullable": true },
"requiredNullable": { "type": "string", "nullable": true },
"requiredNotNullable": { "type": "string" }
},
"required": ["requiredNullable", "requiredNotNullable"],
"type": "object"
} I can't think of a good suggestion on how to proceed though. |
One solution might be to use newtype wrappers for the field types, and typeclass instances, that implement each of the possible behaviors. |
Just to note: IIRC |
Came here because I'm also currently being bitten by this. I think it's still worth tracking this feature even though 3.1 is dropping foo:
type: string
nullable: true By instead doing: foo:
type:
anyOf:
- type: string
- type: "null" So there is still a feature here about changing the spec based on |
Hi,
in OpenAPI standard a field needs to be marked as
nullable: true
if it can containnull
value. When not usingomitNothingFields
in Aeson (default setting),openapi3
lib doesn't mark these fields as nullable, but it should.The function fromAesonOptions ignores
omitNothingFields
, probably it would be better to not ignore it but use to determine whether to add thenullable
attribute or not.What do you think?
The text was updated successfully, but these errors were encountered: