From 133f1ab77dde2ca574a654605e786411a482d576 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Fri, 10 Mar 2017 13:30:23 +0100 Subject: [PATCH] Add demo to show capability of oneOf attribute --- demo/swagger.yaml | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/demo/swagger.yaml b/demo/swagger.yaml index f21ecef5..41493443 100644 --- a/demo/swagger.yaml +++ b/demo/swagger.yaml @@ -292,6 +292,76 @@ paths: - petstore_auth: - 'write:pets' - 'read:pets' + '/pet/{petId}/behaviors': + put: + tags: + - pet + summary: Change behaviors + description: Update the pet's behaviors + operationId: updateBehavior + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + type: integer + format: int64 + - name: body + in: body + required: true + schema: + oneOf: + - $ref: "#/definitions/CatBehavior" + - $ref: "#/definitions/DogBehavior" + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + consumes: + - application/x-www-form-urlencoded + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + type: integer + format: int64 + - name: name + in: formData + description: Updated name of the pet + required: false + type: string + - name: status + in: formData + description: Updated status of the pet + required: false + type: string + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' /pet/findByStatus: get: tags: @@ -653,12 +723,34 @@ definitions: type: string message: type: string + + CatBehavior: + type: object + properties: + mainTrait: + type: string + enum: + - cuddly + - aggressive + - lazy + + dangerous: + type: boolean + + Cat: description: A representation of a cat allOf: - $ref: '#/definitions/Pet' - type: object properties: + behaviors: + type: array + default: [] + description: A list of behaviors for this Cat + items: + $ref: "#/definitions/CatBehavior" + huntingSkill: type: string description: The measured skill for hunting @@ -668,6 +760,7 @@ definitions: - lazy - adventurous - aggressive + required: - huntingSkill Category: @@ -690,12 +783,32 @@ definitions: description: Dumb Property xml: name: Category + + DogBehavior: + type: object + properties: + mainTrait: + type: string + enum: + - noisy + - slimy + - dependent + + dangerous: + type: boolean + Dog: description: A representation of a dog allOf: - $ref: '#/definitions/Pet' - type: object properties: + behaviors: + type: array + default: [] + description: A list of behaviors for this Dog + items: + $ref: "#/definitions/DogBehavior" packSize: type: integer format: int32