Skip to content
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][DefaultCodegen] OneOf with discriminator for referenced object with allOf #19261

Open
5 of 6 tasks
Axent96 opened this issue Jul 29, 2024 · 0 comments
Open
5 of 6 tasks

Comments

@Axent96
Copy link

Axent96 commented Jul 29, 2024

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Warninng: [main] WARN o.o.codegen.DefaultCodegen - 'GeneralProduct' defines discriminator 'type', but the referenced schema 'HomeProduct' is incorrect. type is missing from the schema, define it as required and type string

openapi-generator version

7.7.0

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: test
  description: Test
  version: "2.0"
servers:
  - url: 'https://example.com'
security:
  - APIKeyHeader: []
paths:
  /products/{identifier}:
    get:
      tags:
        - Product Item
      summary: Get single product
      parameters:
        - name: identifier
          in: path
          required: true
          schema:
            type: string
          example: "100001951"
          description: The product identifier
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeneralProduct'
components:
  schemas:
    GeneralProduct:
      type: object
      oneOf:
        - $ref: '#/components/schemas/HomeProduct'
        - $ref: '#/components/schemas/InternetProduct'
      discriminator:
        propertyName: type
        mapping:
          home: '#/components/schemas/HomeProduct'
          internet: '#/components/schemas/InternetProduct'
    HomeProduct:
      allOf:
        - $ref: "#/components/schemas/Product"
        - type: object
          required:
            - newField
          properties:
            newField:
              type: string
    InternetProduct:
      allOf:
        - $ref: "#/components/schemas/Product"
        - type: object
          required:
            - extraField
          properties:
            extraField:
              type: string
    Product:
      type: object
      required:
        - productId
        - name
        - type
      properties:
        productId:
          type: string
        name:
          type: string
        type:
          $ref: '#/components/schemas/AboType'
    AboType:
      type: string
      enum:
        - "internet"
        - "home"
Generation Details

java -jar codegen/openapi-generator-cli-7.7.0.jar generate -i ./api.json -g php --invoker-package=Test\Main --api-package=Client --model-package=Models --additional-properties=variableNamingConvention=camelCase --additional-properties=disallowAdditionalPropertiesIfNotPresent=false --additional-properties=legacyDiscriminatorBehavior=false -o /tmp/

Steps to reproduce

Generate a library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant