fastapi-code-generator: $refs in parameter is not processed
I expect
$refs in parameters to be processed, eg
paths:
/foo:
parameters:
- $ref: '#/components/parameters/MyParam'
components:
parameters:
MyParam:
name: foo
schema:
type: string
Instead
I get KeyError
File "/usr/local/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 207, in get_parameter_type
schema: JsonSchemaObject = JsonSchemaObject.parse_obj(parameter["schema"])
KeyError: 'schema'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 29 (17 by maintainers)
@oktavlachs
I didn’t know it.
I guess
openapi-generator-clisupports openapi features like multiple status codes of responses. (But, We can implement the features to fastapi-code-generator.) Also, the code-generator creates project files (tests, docker file, …)However,
openapi-generator-clican generate only a simple model. https://github.com/OpenAPITools/openapi-generator/commit/0da409986889dcfab1420fb1410ae9509a5834c8#diff-b667e564efa49b2fa6b6d766c52b062dc73f3e6444046e34d9457d6e532e91e0fastapi-code-generatorusedatamodel-code-generatorto generate models. Thedatamodel-code-generatorsupports a lot of features. For example,allOfis created as an inherited class. I believe definitely this is the best advantage.Btw,
datamodel-code-generatoris used in a lot of projects. It’s download about 100k per month. Famous tech compies convert complex and large Schema files to pydantic models bydatamodel-code-generator. 😉If fastapi-code-generator can call all features of datamodel-code-generator then I guess fastapi-code-generator becomes an awesome tool to generate fastapi and pydnatic code.
@koxudaxi yes,
parameterscan acceptcontentin OAS3. It is the first time I see it though 😃 https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.1.md#parameterObjectThanks! As it still does not support remote refs, I’ll close this and file another! Great work!
I confirm it is now working well with version 0.0.16 even with some nested refs. Great work ! Thanks.
@oktavlachs Thank you for posting the problem. I have not known that
parameterscan acceptcontent. OK, I will fix it.