Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8044
Closed
Open
Issue created Nov 28, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] Broken generation of anyOf model in python client

Created by: generall

Bug 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 with model = PayloadInterface(value="text", type="keyword")
  • Observe error: Invalid value for 'type' (keyword), must be one of ['float']
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking