Skip to content

Instantly share code, notes, and snippets.

@fehguy
Last active January 3, 2016 12:09
Show Gist options
  • Save fehguy/8461152 to your computer and use it in GitHub Desktop.
Save fehguy/8461152 to your computer and use it in GitHub Desktop.
input vs. output models described with subtypes
apiVersion: 1.0.0
swaggerVersion: "1.2"
basePath: "http://localhost:8002/api"
resourcePath: /pet
produces:
- application/json
- application/xml
- text/plain
- text/html
apis:
- path: /user
operations:
- method: POST
summary: Add a user
notes: ""
type: OutputUser
nickname: addUser
parameters:
- name: body
description: User to add
required: true
allowMultiple: false
type: User
paramType: body
responseMessages:
- code: 400
message: Invalid pet
models:
User:
id: User
description: The base user
required:
- name
properties:
username:
type: string
subTypes:
- OutputUser
OutputUser:
id: OutputUser
description: A user with internal values
required:
- id
properties:
id:
type: integer
format: int64
{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "http://localhost:8002/api",
"resourcePath": "/pet",
"produces": [
"application/json",
"application/xml",
"text/plain",
"text/html"
],
"apis": [
{
"path": "/user",
"operations": [
{
"method": "POST",
"summary": "Add a user",
"notes": "",
"type": "OutputUser",
"nickname": "addUser",
"parameters": [
{
"name": "body",
"description": "User to add",
"required": true,
"allowMultiple": false,
"type": "User",
"paramType": "body"
}
],
"responseMessages": [
{
"code": 400,
"message": "Invalid pet"
}
]
}
]
}
],
"models": {
"User": {
"id": "User",
"description": "The base user",
"required": [
"name"
],
"properties": {
"username": {
"type": "string"
}
},
"subTypes": [
"OutputUser"
]
},
"OutputUser": {
"id": "OutputUser",
"description": "A user with internal values",
"required": [
"id"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
}
}
}
}
@fehguy
Copy link
Author

fehguy commented Jan 16, 2014

The OutputUser contains a service-generated id field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment