Skip to content

Instantly share code, notes, and snippets.

@mheap
Last active April 27, 2024 18:51
Show Gist options
  • Save mheap/99d32429e2f579cce925d968aa30e6a9 to your computer and use it in GitHub Desktop.
Save mheap/99d32429e2f579cce925d968aa30e6a9 to your computer and use it in GitHub Desktop.
openapi: 3.0.2
info:
title: Swagger Petstore - Schema Inheritence
description: |
This is a sample OpenAPI file to show schema inheritence
version: 1.0.0
servers:
- url: /api/v3
tags:
- name: Pet
description: Everything about your Pets
paths:
/pet:
get:
tags:
- Pet
summary: List available pets in the store
operationId: listPets
responses:
"200":
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Pet"
post:
tags:
- Pet
summary: Add a new pet to the store
operationId: addPet
requestBody:
description: Create a new pet in the store
content:
application/json:
schema:
$ref: "#/components/schemas/CreatePetRequest"
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/PetWithDetails"
/pet/{petId}:
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
get:
tags:
- Pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/PetWithDetails"
put:
tags:
- Pet
summary: Update an existing pet
operationId: updatePet
requestBody:
description: Update an existent pet in the store
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/PetWithDetails"
components:
schemas:
CreatePetRequest:
type: object
properties:
name:
type: string
type:
type: string
Pet:
allOf:
- $ref: "#/components/schemas/CreatePetRequest"
- type: object
properties:
adopted_at:
type: string
created_at:
type: string
readOnly: true
PetWithDetails:
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
properties:
total_steps:
type: string
readOnly: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment