Files
connexion/examples/sqlalchemy/spec/openapi.yaml
Robbe Sneyders 1211d1b655 Enable enforcing defaults (#1616)
This PR is a proposal to enforce defaults in json bodies.

The standard JsonRequestBodyValidator does not adapt the body. Instead, I added a DefaultsJsonRequestBodyValidator which does. The user can easily activate enforcing default by passing this Validator in a validator_map.

I would have liked connexion to have an enforce_defaults flag, but it would be hard to make this compatible with the validator_map argument.
2023-01-26 15:08:27 +01:00

121 lines
2.7 KiB
YAML

openapi: 3.0.0
servers:
- url: /openapi
info:
title: Pet Shop Example API
version: '0.1'
paths:
/pets:
get:
tags:
- Pets
operationId: app.get_pets
summary: Get all pets
parameters:
- name: animal_type
in: query
schema:
type: string
pattern: '^[a-zA-Z0-9]*$'
- name: limit
in: query
schema:
type: integer
minimum: 0
default: 100
responses:
'200':
description: Return pets
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'/pets/{pet_id}':
get:
tags:
- Pets
operationId: app.get_pet
summary: Get a single pet
parameters:
- $ref: '#/components/parameters/pet_id'
responses:
'200':
description: Return pet
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'404':
description: Pet does not exist
put:
tags:
- Pets
operationId: app.put_pet
summary: Create or update a pet
parameters:
- $ref: '#/components/parameters/pet_id'
responses:
'200':
description: Pet updated
'201':
description: New pet created
requestBody:
x-body-name: pet
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
delete:
tags:
- Pets
operationId: app.delete_pet
summary: Remove a pet
parameters:
- $ref: '#/components/parameters/pet_id'
responses:
'204':
description: Pet was deleted
'404':
description: Pet does not exist
components:
parameters:
pet_id:
name: pet_id
description: Pet's Unique identifier
in: path
required: true
schema:
type: string
pattern: '^[a-zA-Z0-9-]+$'
schemas:
Pet:
type: object
required:
- name
- animal_type
properties:
id:
type: string
description: Unique identifier
example: '123'
readOnly: true
name:
type: string
description: Pet's name
example: Susie
minLength: 1
maxLength: 100
animal_type:
type: string
description: Kind of animal
example: cat
minLength: 1
created:
type: string
format: date-time
description: Creation time
example: '2015-07-07T15:49:51.230+02:00'
readOnly: true