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-experimental] Certain types in nested component schemas are interpreted as DynamicSchema #3
[BUG] [Python-experimental] Certain types in nested component schemas are interpreted as DynamicSchema #3
Comments
This is an important use case. Thank you for reporting this bug. The solution is to convert all ingested instances into their primitive types (dict/list/str/int/bool/None) and store the erlier completed validations from the DynamicSchema class into the ValidationMetadata. Then those schema classes will not have to rerun validations that were already run in Age when a Dog instance is instantiated using an |
@mikeknep a short term work around for this is to use |
All fixed, please pull the latest master branch (commit d6b360d or later) and regenerate your client using it. |
@mikeknep what is this HashMap error you are referring to? I am also getting it! Using your workaround for now! Note that My spec yaml, it has been validated. Run:
Error:
|
@caniko are you able to instantiate models using |
@spacether I am not sure I follow. Could you expand a bit? |
The original issue has 2 pieces
Piece 2 has been fixed in an earlier PR, that' why the issue was closed. |
Actually, the generated code are missing some models. I used these options: Note that the error on my first post was resolved with these options. So, piece 1 is not an issue anymore. I am working with |
My models were fine on The code gen is just fine with * = mixup between operators |
Missing models are a very fixable bug. Which models are missing? |
Closing this issue
@caniko 's issue happened because of these logged messages:
|
Bug Report Checklist
Description
I am unable to construct a python-experimental-generated object that includes both a nested component schema property and
allOf
. Certain types (integer, number, boolean) become impossible to construct, being interpreted as aDynamicSchema
instead of the actual type.openapi-generator version
6.0.0
OpenAPI declaration file content or url
Generation Details
I've generated the schema above with both the standard python generator and python-experimental for side-by-side comparisons:
(Note: the
_JAVA_OPTIONS
are passed to avoid this error:)Steps to reproduce
The standard Dog can be created just fine, but the experimental Dog cannot be constructed:
I've changed the type of
value
to a few different simple types—string works fine, but integer/number/boolean all fail.Related issues/PRs
None to my knowledge
Suggest a fix
Per @spacether:
For wider context of my real-world use case: I have an API endpoint with a polymorphic request body—it can accept
oneOf
several animals (to run with the reproduction example). I have several different animals (not just two), and while most have pretty distinct properties (as above—Dog and Cat are quite distinct from one another), a few of them happen to have the exact same set of fields (say...name
andnumber_of_legs
). I need to be able to disambiguate between two animals with identical properties, so I'm adding thespecies
field as a discriminator. Each specific animal defines species as an enum-of-one field to ensure a client doesn't create something likeGiraffe(species="canine")
.In my real-world example there are additional, common, sometimes-optional properties that all Animals define, which is why I'm using
allOf
. Maybe thespecies
property and discriminator mapping is not actually necessary in this case (since its hard-coded on each concrete animal schema), and I should just perform server-side switching using that field myself? I had assumed providing the discriminator block would yield some benefit in generated code. (Still pretty new to this tool in general so I don't know for sure, but all the polymorphism examples in the docs talk about using it.)The text was updated successfully, but these errors were encountered: