-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] Using allOf
and $ref
generates an object
in the python model when it should be a string
#8457
Comments
Why not change your spec to have access_token point directly to the referenced #/components/schemas/AccessToken without using allOf? That should solve your problem. |
@spacether reading here: https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
|
Yes, I agree that there is a bug here. My suggestion is a work around which may work for you. |
Oh I see. Yep that does fix my problem :D! |
Hmm spoke too soon. Any timeline on better |
No firm timeline here. I am slowly working on a number of improvementss to the Python generator in a new generator python-experimental. This feature will be included in that. The issue is not with ref support. It is with inline composed schema support. |
For this use case you can delete your AccessToken schema and just define BankTransferCreateRequest.access_token as |
@spacether I see. May have to make a workaround for just |
How about: |
Ruby, Node, Python, Go, Java and js client side SwaggerParser for our docs. Ive run into another issue with using |
Going off the Swagger docs this format should be valid. |
It is a valid spec, our tooling just isn't there yet.
|
I think we have a workaround for now. Thanks for talking through it @spacether!! Hoping to get a sponsorship going here soon for you all. |
I've got the same issue but slightly different. I've got a PatientScanDto:
type: object
patient:
allOf:
- $ref: '#/components/schemas/PatientInfoDto'
nullable: true
readOnly: true PatientInfoDto:
type: object
properties:
patientId:
type: string Python classes However the property In generator version Generator version |
If you define patient as its own component and then $ref to patient in PatientScanDto does this work? |
Just for clarity here, I want to describe the openapi definition of your specs
BankTransferCreateRequest.access_token does not define a type so it allows in any type in the
PatientScanDto.patient allows in any type of payload because type is unset. However because PatientInfoDto further constrains the payload to only be type object, only object type payloads will pass validation. |
For components with allOf this is working in the python-experimental generator. |
@spacether thanks for your reply, you are right, I guess you're also right about your assumption that it's an inline issue. You mentioned that in an older answer already. In my use case the spec is generated by another framework with inline objects and then serves to generated kind of a proxy server. Currently I need to modify the spec manually before generating the server. |
Can you try your spec with python-experimental and see if it works? In the future I will add more inline examples to the python-experimental generator to see how well it is handling them in all locations. Endpoints are definitely sometimes generating inline schemas for parameters in the endpoint files. If any locations are not working I will have to turn the inline model resolver off for python experimental so the generator will handle the spec exactly as it was defined by the user. |
Re-opening this until examples have been added in python-experimental verifying that this is working at levels deeper than a root component with composition. Tests are needed of:
|
The merged PR #11420
So this feature works in Please switch to the |
Bug Report Checklist
Description
openapi-generator version
Docker CLI latest
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Run the generator, try accessing the
BankTransferCreateRequest
model. See thataccess_token
isobject
instead ofstring
.Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: