Open imyixiao opened 7 months ago
when the allof class has nested oneof inside, the allof class will ignore oneof requirements and take in all the fields of the oneof classes
expected:
class Cat(BaseModel): """ Kitty """ # data type: Kitty1 oneof_schema_1_validator: Optional[Kitty1] = None # data type: Kitty2 oneof_schema_2_validator: Optional[Kitty2] = None actual_instance: Optional[Union[Kitty1, Kitty2]] = None one_of_schemas: Set[str] = { "Kitty1", "Kitty2" } color: Optional[StrictStr] = None
actual result
class Cat(BaseModel): """ Cat """ # noqa: E501 size: Optional[StrictInt] = None food: Optional[StrictInt] = None color: Optional[StrictStr] = None __properties: ClassVar[List[str]] = ["size", "food", "color"]
7.4
openapi: 3.0.0 info: title: API description: api. version: 1.4.0 paths: /pets: patch: requestBody: content: application/json: schema: $ref: "#/components/schemas/Cat" responses: "200": description: Updated components: schemas: Cat: type: object allOf: - $ref: "#/components/schemas/Kitty" - $ref: "#/components/schemas/Tiger" Kitty: type: object oneOf: - $ref: "#/components/schemas/Kitty1" - $ref: "#/components/schemas/Kitty2" Kitty1: type: object properties: size: type: integer Kitty2: type: object properties: food: type: integer Tiger: type: object properties: color: type: string
java -jar openapi-generator-cli-7.4.0.jar generate -i $spec_file -g python -o $output_folder --package-name $package_name
https://github.com/OpenAPITools/openapi-generator/issues/16150
however if the allof only has one item, it will be fine.
Cat: type: object allOf: - $ref: "#/components/schemas/Kitty"
Bug Report Checklist
Description
when the allof class has nested oneof inside, the allof class will ignore oneof requirements and take in all the fields of the oneof classes
expected:
actual result
openapi-generator version
7.4
OpenAPI declaration file content or url
Generation Details
java -jar openapi-generator-cli-7.4.0.jar generate -i $spec_file -g python -o $output_folder --package-name $package_name
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/16150
Suggest a fix