ogen-go / ogen

OpenAPI v3 code generator for go
https://ogen.dev
Apache License 2.0
1.46k stars 86 forks source link

Discriminator Inference Regression: Specification working with 1.1.1 no longer works in 1.2.x #1255

Closed silvestre closed 5 months ago

silvestre commented 6 months ago

What version of ogen are you using?

Working: 1.1.1 Not working: 1.2.0, 1.2.1

Can this issue be reproduced with the latest version?

Yes

What did you do?

We run in cloudfoundry/app-autoscaler-release via generate.go

go run github.com/ogen-go/ogen/cmd/ogen --config ogen-config.yaml --package scalinghistory --target scalinghistory --clean ../../../../api/scaling-history-api.openapi.yaml

with the config just being:

parser:
  allow_remote: true

and the OpenAPI spec scaling-history-api.openapi.yaml, containing the following schemas:

    HistoryEntry:
      description: "Properties common for each entry in the scaling history."
      type: object
      oneOf:
        - $ref: "#/components/schemas/HistoryErrorEntry"
        - $ref: "#/components/schemas/HistoryIgnoreEntry"
        - $ref: "#/components/schemas/HistorySuccessEntry"
      properties:
       [... many shared properties, e.g.]
        message:
          type: string
          description: Textual information about the scaling event.
          example: app
    HistoryErrorEntry:
      description: Description of a failed scaling even in history.
      type: object
      properties:
        error:
          type: string
          description: |
            In case the scaling failed, the reason is provided in this field.
          example: failed to compute new app instances
    HistoryIgnoreEntry:
      description: Description of an ignored scaling event in history.
      type: object
      properties:
        ignore_reason:
          type: string
          description: |
            In case the scaling was ignored, the reason is provided in this field.
          example: app in cooldown period
    HistorySuccessEntry:
      description: Description of a successful scaling event event in history.
      type: object
      properties: {} # No extra fields needed in this variant.

What did you expect to see?

With ogen versions up to 1.1.1 client and server code was generated and has been used by us productively.

What did you see instead?

Starting with 1.2.0 we get an error message:

Feature "discriminator inference" is not implemented yet.

Try to create ogen.yml with:

generator:
        ignore_not_implemented: ["discriminator inference"]

or

generator:
        ignore_not_implemented: ["all"]

to skip unsupported operations.