Skip to content

allow coexistence of anyOf and oneOf fields in single schema definition #839

Closed

Description

@masu-mi

allow coexistence of anyOf and oneOf fields in single schema definition

If some schema has anyOf, oneOf field, generating code get failed. (A while ago (before of commit:5a1784a), generating get success, but generated code didn't work)
Its reason is that created internal type name for additional type related to anyOf or oneOf.

I want to fix it, but have no idea how to escape the name conflict, using Any and One suffixes for them?

example

We can reproduce it executing go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --config=config.yaml spec.yaml with following files.

config.yml

---
package: issue_any_w_one
generate:
  models: true
output: issue.gen.go
output-options:
  skip-prune: true

spec.yaml

openapi: 3.0.2
info:
  version: "0.0.1"
components:
  schemas:
    Orange:
      desription: anyOf with oneOf
      oneOf:
      - required:
        - attrA0
      - required:
        - attrA1
      anyOf:
      - required:
        - attrB
      - required:
        - attrC
      properties:
        attrA0: {type: string}
        attrA1: {type: string}
        attrB: {type: string}
        attrC: {type: string}
      type: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions