Replies: 7 comments
-
|
Beta Was this translation helpful? Give feedback.
-
{"openapi":"3.0.2","info":{"title":"Fast API","version":"0.1.0"},"paths":{"/":{"post":{"summary":"Main","operationId":"main__post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_main__post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"Body_main__post":{"title":"Body_main__post","required":["file"],"type":"object","properties":{"file":{"title":"File","type":"string","format":"binary"}}},"Foo":{"title":"Foo","required":["span"],"type":"object","properties":{"span":{"title":"Span","type":"array","items":[{"type":"integer"},{"type":"integer"}]}}},"HTTPValidationError":{"title":"HTTPValidationError","type":"object","properties":{"detail":{"title":"Detail","type":"array","items":{"$ref":"#/components/schemas/ValidationError"}}}},"ValidationError":{"title":"ValidationError","required":["loc","msg","type"],"type":"object","properties":{"loc":{"title":"Location","type":"array","items":{"type":"string"}},"msg":{"title":"Message","type":"string"},"type":{"title":"Error Type","type":"string"}}}}}} Is this a problem to render the schema in |
Beta Was this translation helpful? Give feedback.
-
I pasted the schema to Swagger Editor and confirmed that this schema is invalid. |
Beta Was this translation helpful? Give feedback.
-
@dmontagu What do you think about? |
Beta Was this translation helpful? Give feedback.
-
Thanks for following up. Yeah I’m not sure what the best thing to do is here. Given how much there is to support I’m generally okay with it if we just properly support what’s the same in both JSON Schema and OpenAPI. I’d be open to changing the behavior (or trying to get it changed anyway) given enough interest. Or if @tiangolo thinks it’s best. You can manually override the generated schema using |
Beta Was this translation helpful? Give feedback.
-
The thing is that OpenAPI explicitly forbids lists with multiple sub-schemas (tuples). So, you can't declare tuples with OpenAPI even though you can with JSON Schema. If you need to have tuples in your model (i.e. you can't declare it as a list) the best way to go would probably be as @dmontagu says by adding a |
Beta Was this translation helpful? Give feedback.
-
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem
I have a model
Foo
to be used as response class:However, this generates empty typed json schema:
I want
Foo
to be generated[interger]
in json shcema.The solution you would like
Tuple
is converted toList
in json schema.Describe alternatives you've considered
Rewrite
Foo.span
type annotation toList[int]
.Beta Was this translation helpful? Give feedback.
All reactions