Skip to content

Schema reference having a same name as the schema in parent document #1940

@r-sreesaran

Description

@r-sreesaran

Consider having two open api documents.

 info:
  title: Common Data Types
  version: "1.0"
paths:
  /subscriptions:
    get:
      summary: read all of the active subscriptions for the app.
      operationId: getSubscriptionsById
      parameters:
        - name: appId
          in: path
          description: App ID
          required: true
          schema:
            type: integer
            format: int64
      responses:
        '200':
          description: OK (Successful)
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Subscription'
        '500':
          $ref: './issue-1108-1.yaml#/components/responses/E500'
        '501':
          $ref: '#/components/schemas/ProblemDetails' 
components:
  schemas:
    ProblemDetails:
      type: object
      properties:
        title:
          type: string
          description: A short, human-readable summary of the problem
        status:
          type: integer
          description: The HTTP status code for this occurrence of the problem.
    Subscription:
      type: string

Open api document for sample.yaml

info:
  title: Common Data Types
  version: "1.0"
paths: {}
components:
  responses:
    E500:
      description: Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ProblemDetails'
  schemas:
   ProblemDetails:
      type: object        

Here there are two schema having the same name. Can this be referenced like wise.
Open API cannot have duplicate schema under components.
By this there totally two schema with the same.

can you point me towards the part of the specification that clarifies the part about referencing schema with name as in original document or can you shed some light as to the correctness of my understanding and validate where this is correct ?.

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