|
| 1 | +openapi: 3.1.0 # The version of the OpenAPI Specification |
| 2 | +info: # Metadata about the API |
| 3 | + title: A simple OpenAPI 3.1 example |
| 4 | + version: 1.0.0 |
| 5 | + license: |
| 6 | + name: Apache 2.0 |
| 7 | + identifier: Apache-2.0 # The SPDX license identifier |
| 8 | +paths: # The available paths and operations for the API |
| 9 | + /echo: # A path for echoing messages using WebSockets |
| 10 | + get: # An operation using the GET method |
| 11 | + summary: Echo a message |
| 12 | + description: Send a message to the server and receive the same message back |
| 13 | + responses: |
| 14 | + '101': |
| 15 | + description: Switching Protocols |
| 16 | + headers: |
| 17 | + Upgrade: |
| 18 | + schema: |
| 19 | + type: string |
| 20 | + enum: |
| 21 | + - websocket |
| 22 | + Connection: |
| 23 | + schema: |
| 24 | + type: string |
| 25 | + enum: |
| 26 | + - Upgrade |
| 27 | + Sec-WebSocket-Accept: |
| 28 | + schema: |
| 29 | + type: string |
| 30 | + content: {} # No content is returned for this response |
| 31 | + servers: |
| 32 | + - url: ws://example.com # The WebSocket server URL |
| 33 | + /upload: # A path for uploading files using multipart/form-data |
| 34 | + post: # An operation using the POST method |
| 35 | + summary: Upload a file |
| 36 | + description: Upload a file to the server and receive a confirmation message |
| 37 | + requestBody: |
| 38 | + required: true |
| 39 | + content: |
| 40 | + multipart/form-data: # The media type for sending multiple parts of data |
| 41 | + schema: |
| 42 | + type: object |
| 43 | + properties: |
| 44 | + file: # A property for the file data |
| 45 | + type: string |
| 46 | + format: binary |
| 47 | + comment: # A property for the file comment |
| 48 | + type: string |
| 49 | + encoding: # The encoding for each part of data |
| 50 | + file: |
| 51 | + contentType: application/octet-stream # The media type for the file data |
| 52 | + comment: |
| 53 | + contentType: text/plain # The media type for the file comment |
| 54 | + responses: |
| 55 | + '200': |
| 56 | + description: File uploaded successfully |
| 57 | + content: |
| 58 | + application/json: # The media type for the response body |
| 59 | + schema: |
| 60 | + type: object |
| 61 | + properties: |
| 62 | + message: # A property for the confirmation message |
| 63 | + type: string |
| 64 | + example: File uploaded successfully |
| 65 | +components: # Reusable components for the API |
| 66 | + schemas: # JSON Schema definitions for the API |
| 67 | + User: # A schema for a user object |
| 68 | + $id: http://example.com/schemas/user # The identifier for the schema |
| 69 | + type: object |
| 70 | + properties: |
| 71 | + name: # A property for the user name |
| 72 | + type: string |
| 73 | + default: "John Doe" # The default value for the user name |
| 74 | + age: # A property for the user age |
| 75 | + type: integer |
| 76 | + minimum: 0 |
| 77 | + default: 18 # The default value for the user age |
| 78 | + unevaluatedProperties: false # No additional properties are allowed |
| 79 | + Pet: # A schema for a pet object |
| 80 | + type: object |
| 81 | + required: |
| 82 | + - petType |
| 83 | + properties: |
| 84 | + petType: # A property for the pet type |
| 85 | + type: string |
| 86 | + discriminator: # The discriminator for resolving the concrete schema type |
| 87 | + propertyName: petType |
| 88 | + mapping: |
| 89 | + cat: '#/components/schemas/Cat' |
| 90 | + dog: '#/components/schemas/Dog' |
| 91 | + Cat: # A schema for a cat object |
| 92 | + allOf: |
| 93 | + - $ref: '#/components/schemas/Pet' |
| 94 | + - type: object |
| 95 | + properties: |
| 96 | + name: # A property for the cat name |
| 97 | + type: string |
| 98 | + default: "Fluffy" # The default value for the cat name |
| 99 | + Dog: # A schema for a dog object |
| 100 | + allOf: |
| 101 | + - $ref: '#/components/schemas/Pet' |
| 102 | + - type: object |
| 103 | + properties: |
| 104 | + bark: # A property for the dog bark |
| 105 | + type: string |
| 106 | + default: "Woof" # The default value for the dog bark |
0 commit comments