[BUG] Broken generation of anyOf model in python client
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What’s the actual output vs expected output?
Description
Python client model is generated with broken validation in case of anyOf specification. Model entry point tends to validate any option with the fields from latest entrance, which make it impossible to create instance other that the last option of anyOf.
openapi-generator version
latest + v5.0.0-beta3
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Bug API
version: 0.1.0
paths:
/test/:
post:
summary: Update points in collection
operationId: update_points
requestBody:
description: Points update operations
content:
application/json:
schema:
$ref: "#/components/schemas/PayloadInterface"
responses:
200:
description: successful operation
components:
schemas:
PayloadInterface:
anyOf:
- properties:
type:
enum:
- keyword
type: string
value:
type: string
required:
- type
- value
type: object
- properties:
type:
enum:
- float
type: string
value:
format: double
type: number
required:
- type
- value
type: object
Generation Details
docker run --rm \
-u $(id -u ${USER}):$(id -g ${USER}) \
-v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
-i /local/openapi.yaml \
-g python \
-o /local/test_client
Steps to reproduce
- Generate client with given specification and command.
- Try to create model
PayloadInterface
withmodel = PayloadInterface(value="text", type="keyword")
- Observe error:
Invalid value for 'type' (keyword), must be one of ['float']
Related issues/PRs
Suggest a fix
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
[BUG][PYTHON] Using Openapi 3.0 Inheritance/Polymorphism ...
[BUG][PYTHON] Using Openapi 3.0 Inheritance/Polymorphism keywords (allOf, anyOf, oneOf) causes generation of UNKNOWNBASETYPE model. #8892.
Read more >DataStax Python Driver - CHANGELOG
DETERMINISTIC clause in AGGREGATE misplaced in CQL generation (PYTHON-963). graph module import cause a DLL issue on Windows due to its cythonizing failure ......
Read more >What's New In Python 3.9 — Python 3.11.1 documentation
For the majority of use cases, users can leverage the Abstract Syntax Tree (AST) generation and compilation stage, using the ast module. The...
Read more >Troubleshoot Dataflow errors - Google Cloud
If you run into problems with your Dataflow pipeline or job, this page lists error messages that you might see and provides suggestions...
Read more >An adventure in OpenAPI V3 code generation | Mux blog
OpenAPI Generator is a comprehensive Java application which can generate client and server side code from your OpenAPI models.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#8892 Is it connected?
This works in
python-experimental
please use it