Skip to content

Instantly share code, notes, and snippets.

@johanste
Last active January 13, 2021 21:55
Show Gist options
  • Save johanste/de97066c4ec712a6a833928cf59ff776 to your computer and use it in GitHub Desktop.
Save johanste/de97066c4ec712a6a833928cf59ff776 to your computer and use it in GitHub Desktop.
Show how to use the (autorest) x-ms-paths extension to overload operations for the same path.
{
"swagger": "2.0",
"info": {
"title": "Show x-ms-paths",
"version": "1.0"
},
"x-ms-paths": {
/* Note - fake query parameter to make the path unique. Not actually used in the API.
You can also differentiate using a different path parameter name if the path is parameterized
*/
"/pets/{name}?dog": {
"put": {
"parameters": [
{
"name": "dog",
"in": "body",
"required": true,
"schema": {
"$ref": "/definitions/Dog"
}
},
{
"name": "name",
"in": "path",
"required": true,
"type": "string"
}
],
"responses": {
"201": {
"description": "Created a Dog",
"schema": {
"$ref": "/definitions/Dog"
}
}
}
}
},
"/pets/{name}?cat": {
"put": {
"parameters": [
{
"name": "cat",
"in": "body",
"required": true,
"schema": {
"$ref": "/definitions/Cat"
}
},
{
"name": "name",
"in": "path",
"required": true,
"type": "string"
}
],
"responses": {
"201": {
"description": "Created a Cat",
"schema": {
"$ref": "/definitions/Cat"
}
}
}
}
}
},
"definitions": {
"Dog": {
"type": "object",
"properties": {
"bark": {
"type": "string"
}
}
},
"Cat": {
"type": "object",
"properties": {
"meow": {
"type": "string"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment