-
Notifications
You must be signed in to change notification settings - Fork 10
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
Literal values are not being correctly serialised for OpenAPI v3 #23
Comments
I've created an appropriate |
Hey @metamoof - version 0.4.0 has just been released which includes the fix I mentioned above - would you mind trying that and let me know if you still have issues? Closing this for now 👍🏼 |
Not sure if intended, an enum with a single type will still get the "const" keyword in v3.0 (https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_0_3/util.py#L108) class InteractableType(str, Enum):
"""
Interactable type.
"""
IMAGE_DISPLAY = "IMAGE_DISPLAY" will produce: "InteractableType": {
"title": "InteractableType",
"enum": [
"IMAGE_DISPLAY"
],
"type": "string",
"description": "Interactable type.",
"const": "IMAGE_DISPLAY"
}, which openapi-generator-cli (for example) will complain about when generating code. If "const" is not a part of v3 spec, it should not be generated. |
I regularly deal with an API where a value is either something that fits some minimal requirements or is an empty string. I've made a small example here:
The output from this is:
My syntax checker tells me
const
is not allowed in a property.Presumably this is permissible under JSON Schemas, but the OpenAPI library should be replacing this with a second
string
block, filtering this out or otherwise flagging it.The text was updated successfully, but these errors were encountered: