Skip to content

Instantly share code, notes, and snippets.

@hodrigohamalho
Created October 19, 2020 08:13
Show Gist options
  • Save hodrigohamalho/c411df530f4b5513a519c0763492cbe5 to your computer and use it in GitHub Desktop.
Save hodrigohamalho/c411df530f4b5513a519c0763492cbe5 to your computer and use it in GitHub Desktop.
users-api.json
{
"openapi": "3.0.2",
"info": {
"title": "Users API",
"version": "1.0.0",
"description": "Users API Specification"
},
"paths": {
"/orders-api/orders": {
"summary": "Path used to manage the list of orders.",
"description": "The REST endpoint/path used to list and create zero or more `order` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively.",
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/order"
}
}
}
},
"description": "Successful response - returns an array of `order` entities."
}
},
"operationId": "getorders",
"summary": "List All orders",
"description": "Gets a list of all `order` entities."
}
},
"/orders-api/orders/{userId}": {
"summary": "Orders for a user",
"description": "Describe all orders from a specific user",
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/order"
}
}
}
},
"description": "All orders from the specified user"
}
},
"operationId": "order-user",
"summary": "Get all orders from a user",
"description": "Get all orders from a user"
},
"parameters": [
{
"name": "userId",
"description": "User Id",
"schema": {
"type": "integer"
},
"in": "path",
"required": true
}
]
},
"/users-api/users": {
"summary": "Path used to manage the list of users.",
"description": "The REST endpoint/path used to list and create zero or more `user` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively.",
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
},
"description": "Successful response - returns an array of `user` entities."
}
},
"operationId": "getusers",
"summary": "List All users",
"description": "Gets a list of all `user` entities."
},
"post": {
"requestBody": {
"description": "A new `user` to be created.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/user"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Successful response."
}
},
"operationId": "createuser",
"summary": "Create a user",
"description": "Creates a new instance of a `user`."
}
}
},
"components": {
"schemas": {
"order": {
"title": "Root Type for order",
"description": "Order details",
"type": "object",
"properties": {
"id": {
"format": "int32",
"type": "integer"
},
"name": {
"type": "string"
},
"price": {
"format": "double",
"type": "number"
},
"user_id": {
"format": "int32",
"type": "integer"
}
},
"example": {
"id": 0,
"name": "Rodrigo Ramalho",
"price": 10.5,
"user_id": 1
}
},
"user": {
"title": "Root Type for user",
"description": "User object",
"type": "object",
"properties": {
"id": {
"format": "int32",
"type": "integer"
},
"name": {
"type": "string"
},
"phone": {
"type": "string"
},
"age": {
"format": "int32",
"type": "integer"
}
},
"example": {
"id": 0,
"name": "Rodrigo Ramalho",
"phone": "11 99555-2211",
"age": 30
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment