-
-
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
[Python] Generated model for component with "allOf" has no attributes #453
Comments
@poli-granot I've submitted #1360 with better support for allOf, oneOf, etc. Please give it a try and let me if you've any feedback. |
I just wanted to add another issue and noticed there is already one open. Maybe you might find my input useful: DescriptionGenerating python client code with yaml listed below will result in model of "another_object" containing only "anotherproperty" instead of additionally "name" from "test_object". openapi-generator version3.3.1 OpenAPI declaration file content or urlopenapi: 3.0.0
info:
description: Test
version: 0.1.0
title: "Test API"
paths:
/objects:
get:
summary: "Get all available objects"
operationId: getObjects
responses:
200:
description: "List of available objects"
content:
application/json:
schema:
type: "array"
items:
allOf:
- $ref: '#/components/schemas/AnotherObject'
default:
description: "standard error"
components:
schemas:
TestObject:
type: "object"
properties:
name:
type: "string"
example: "Testname"
AnotherObject:
allOf:
- $ref: '#/components/schemas/TestObject'
- type: "object"
properties:
anotherproperty:
type: "string" Command line used for generationjava -jar openapi-generator-cli.jar generate -i testapispec.yaml -g python -o out/ Steps to reproduceUse yaml and command line above. See out/openapi_client/models/another_object.py Suggest a fix/enhancement"$refs" should be followed |
Per openapi json schema, each schema must be validated against the same payload.
Because of this independent schema validation, the python (in openapi-generator v6.2.0) generator does not hoist properties from composed schemas higher. If hoisting is done, then there can be collisions of property types and whether or not the properties are required, if they are enum etc. If you use the python client in v6.2.0, the AddEmailContactRequest class will contain the properties:
And the properties in JsonAPIPostRequestWrapper will be validated in that class. |
Description
Given below is a snippet of the input YAML file I am using. I have several components in the original file that are all have the same structure as "AddEmailContactRequest". All of these components' classes are generated without any attributes, although the YAML file is read correctly.
Here is the relevant snippet of the generated code for "AddEmailContactRequest":
While what it should generate is the below code (I manually fixed it because, well, I need to keep working :) ):
NOTE - I am also getting several warnings as follows during generation:
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: object
openapi-generator version
I'm building from branch 4.0.x, but have encountered this problem with tag v3.0.3 as well.
OpenAPI declaration file content or url
Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i path_to_yaml_file_as_seen_above.yaml -g python -o /outputdir -v
Steps to reproduce
Related issues/PRs
I think this might be related to an issue I saw for JAVA generation -
#340
Suggest a fix/enhancement
I wish I knew.. I would fix it myself :)
The text was updated successfully, but these errors were encountered: