Skip to content

"merging two sets of defaults is undefined" is occured when allOf with default value #1379

Closed

Description

@podhmo

This is completely correct OpenAPI doc, but the error is occured.

          schema:
            allOf:
              - $ref: '#/components/schemas/TaskSortEnum'
              - default: -createdAt

result

$ oapi-codegen /tmp/openapi.yaml 
error generating code: error creating operation definitions: error describing global parameters for GET//tasks: error generating type for param (sort): error merging schemas: error merging schemas for AllOf: merging two sets of defaults is undefined

full OpenAPI doc is here

openapi: 3.0.0
info:
  description: ""
  title: tutorial tasklist API
  version: 0.1.0
servers:
  - description: local development server
    url: http://localhost:8888
components:
  schemas:
    Error:
      properties:
        code:
          description: Error code
          format: int32
          type: integer
        message:
          description: Error message
          type: string
      required:
        - code
        - message
      title: Error
      type: object
    Task:
      properties:
        title:
          type: string
        done:
          type: boolean
        createdAt:
          type: string
        updatedAt:
          type: string
      required:
        - title
        - done
        - createdAt
        - updatedAt
      type: object
    TaskSortEnum:
      enum:
        - createdAt
        - -createdAt
        - updatedAt
        - -updatedAt
      type: string
paths:
  /tasks:
    get:
      description: ""
      operationId: ListTask
      parameters:
        - in: query
          name: sort
          schema:
            allOf:
              - $ref: '#/components/schemas/TaskSortEnum'
              - default: -createdAt
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Task'
                type: array
          description: ''
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: default error

Activity

  1. podhmo commented on Dec 8, 2023

    @podhmo
    Author
  2. podhmo commented on Dec 8, 2023

    @podhmo
    Author
  3. florentchauveau commented on Mar 19, 2024

    @florentchauveau
    Contributor

    @jamietanna hello there! can we get this merged? 🙏

    it's been fixed on kin-openapi as well.

  4. dharmab commented on Oct 3, 2024

    @dharmab

    I ran into this today, is there anything I can do to help #1379?

  5. podhmo commented on Oct 4, 2024

    @podhmo
    Author

    This PR is already ready for review, so a merge should fix it.

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

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