Closed metamoof closed 6 months ago
I've created an appropriate GenerateJsonSchema
object to try and pass to OpenAPI, but I can't see how to do that either....
Looks like @hathawsh may be resolving this already? https://github.com/mike-oakley/openapi-pydantic/pull/22/commits/77a58cadf5ba8bad80de4cf00579ed083e651e04
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.