-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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][PYTHON] BOUNTY Unwanted string-to-date coercion in allOf #10812
Comments
Digging in a bit, it seems like the steps causing this are:
I can keep the upconversion from happening by specifying additionalPropertiesType in each subschema, like this: components:
schemas:
thingone:
additionalProperties:
type: string
type: object
properties:
propone:
type: string
thingtwo:
additionalProperties:
type: string
type: object
properties:
proptwo:
type: string
boththings:
allOf:
- $ref: "#/components/schemas/thingone"
- $ref: "#/components/schemas/thingtwo" That works for this toy problem ... but in my real spec, I want to mix thingone and thingtwo with other schemas that contain dates and booleans and all kinds of stuff. So I don't want to limit what types those other things can be. I think my options, if this turns out to be a non-bug, are:
boththings:
type: object
properties:
thingone:
$ref: "#/components/schemas/thingone"
thingtwo:
$ref: "#/components/schemas/thingtwo" I already have a lot of code that assumes
|
Wow, it's more work than I thought, to implement option 2 from my previous comment - the API implementation leverages the fact that thingone and thingtwo are different objects in order to identify which data "belongs" to each and process it differently. I'm increasing my sponshorship to $1,000 for implementing option 3 in the previous comment. |
I am also affected by this defect. I am working around it by applying this patch to
I don't think this is a desirable solution and my use-case may be narrower than others. |
Interesting. I've implemented my option 2 from a couple of comments back, so my product works for now and I'm too busy with launch preparations to really dig into this right now. But FWIW, my original fix was also to patch I'm still hungry for a real fix here, and I do like to give back when I can, so the bounty will stay up for as long as I can keep my funders committed. :) |
BUMP! My funders are balking at keeping this open, compared to the small cost of keeping my openapi spec ugly. I like my code DRY and would really like to use the allOf functionality. I can keep the bounty at $1,000 for a couple of weeks, but after that it will drop to $500, and maybe go away altogether. Here's hoping someone bites on this. If you have any other suggestions to incentivize a fix here - or if I'm thinking about this all wrong in the first place - I'm all ears! |
I am working on a new version of the python generator which will not have this issue.
I intend on releasing it soon. |
Nice! I'm looking forward to checking it out. |
@mariodsantana it is merged. When you have some time can you take a look at it? |
@spacether - just a quick note to let you know I haven't forgotten this. I'm catching up after a week out sick, but I'll soon get a chance to integrate your changes, DRY up my openapi spec, and test it all out so my funders will release the bounty. Thanks for your hard work! |
Still haven't forgotten! I'm finalizing a release and hope to start upgrading dependencies this week! |
Any update here? |
@mariodsantana what's the status? |
@mariodsantana any update here? |
@spacether - I'm not sure when I'll get the time to refactor my spec to make use of (and test) your changes. I've made you wait too long as it is. DM inbound to discuss bounty payment details. Thanks for your work, and apologies for the delay! |
Bug Report Checklist
$250$1,000 (see below!)Description
Using -g python on a spec that has a schema item with a string value, it's usually an integer but it doesn't have to be. When it's an integer that can be parsed as a date, it gets turned into a date. Sometimes. The way I've been able to consistently replicate it is with a composite object using allOf.
In the spec below, there are two schemas called thingone and thingtwo, each an object with two string properties, and another schema called twothings which is an allOf composition of thingone and thingtwo. When processing a twothings response, where all the string properties are of the form YYYYMMDD, the string properties that belong to thingone are coerced into dates.
openapi-generator version
5.3.1-SNAPSHOT using Docker
OpenAPI declaration file content or url
https://gist.github.com/mariodsantana/9944ee3e4d669771bccaeb059ce863a0
Generation Details
Steps to reproduce
I've written a little bash script to do all of the above, see https://gist.github.com/mariodsantana/28477b908e0d50e17cbcddb52161d790
Related issues/PRs
Obviously there's a lot of work going on with composed schemas and allOf &co, but in my ignorance I couldn't find anything that seemed actually related to this.
Suggest a fix
No real idea. I can fix the immediate issue with a small patch to the generated
model_utils.py
but then that keeps legitimate dates from being converted from strings.I'm willing to sponsor this work to the tune of
$250. Maybe more if it turns out to be a complicated issue.ETA: It's turned out to be a complicated issue. I've upped the bounty to $1,000. :)The text was updated successfully, but these errors were encountered: