Skip to content

How do I refer to external securitySchema object ? #1972

Closed
@yuji38kwmt

Description

@yuji38kwmt

I want to split the following file.

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets/{petId}:
    get:
      summary: Get Pet
      operationId: showPetById
      security:
      - Everyone: []      
      tags:
        - animals
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          schema:
            type: string
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
components:
  securitySchemes:
    Everyone:
      description: everyone
      type: "apiKey"
      name: "Authorization"
      in: "header"
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string

I write components object to external file.

petstore-parent.yaml

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets/{petId}:
    get:
      summary: Get Pet
      operationId: showPetById
      security:
      - Everyone: []      
      tags:
        - animals
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          schema:
            type: string
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                $ref: "./petstore-child.yaml#/components/schemas/Pet"

petstore-child.yaml

components:
  securitySchemes:
    Everyone:
      description: everyone
      type: "apiKey"
      name: "Authorization"
      in: "header"
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string

But I do not know how I refer to external securitySchema object.

    get:
      summary: Get Pet
      operationId: showPetById
      security:
      - Everyone: []      

How do I refer to external securitySchema object ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    re-use: ref-everywhereRequests to support referencing in more / all places

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions