Skip to content

Instantly share code, notes, and snippets.

@srir
Created September 29, 2023 22:13
Show Gist options
  • Save srir/8513874d960a2fd5fbb380f484e4ffc0 to your computer and use it in GitHub Desktop.
Save srir/8513874d960a2fd5fbb380f484e4ffc0 to your computer and use it in GitHub Desktop.
openapi-changes MWE
{
"openapi": "3.1.0",
"info": {
"title": "API Reference",
"version": "1.0",
"description": "foo bar"
},
"servers": [
{
"url": "https://api.example.com",
"description": "Production API"
}
],
"paths": {
"/items/{item_id}": {
"get": {
"summary": "Fetch item",
"description": "This endpoint returns an item identified by its item_id.",
"operationId": "fetch-item",
"parameters": [
{
"required": true,
"style": "simple",
"schema": {
"type": "string"
},
"name": "item_id",
"in": "path"
}
],
"responses": {
"200": {
"description": "OK",
"headers": {},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Item"
}
}
}
},
"404": {
"description": "Not Found",
"headers": {},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/404Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Item": {
"properties": {
"id": {
"type": "string",
"title": "Id"
}
},
"type": "object",
"required": [
"id"
],
"title": "Item"
},
"404Error": {
"oneOf": [
{
"$ref": "#/components/schemas/ResourceNotFoundError"
},
{
"$ref": "#/components/schemas/FeatureNotAvailableError"
}
],
"title": "404Error"
},
"ResourceNotFoundError": {
"properties": {
"type": {
"type": "string",
"const": "https://docs2.example.com/reference/error-responses#404-resource-not-found",
"title": "Type"
},
"status": {
"type": "integer",
"const": 404,
"title": "Status"
},
"detail": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Detail"
},
"title": {
"type": "string",
"title": "Title"
}
},
"type": "object",
"required": [
"type",
"status",
"title"
],
"title": "ResourceNotFoundError"
},
"FeatureNotAvailableError": {
"properties": {
"type": {
"type": "string",
"const": "https://docs2.example.com/reference/error-responses#404-feature-not-available",
"title": "Type"
},
"status": {
"type": "integer",
"const": 400,
"title": "Status"
},
"detail": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Detail"
},
"title": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Title"
}
},
"type": "object",
"required": [
"type",
"status"
],
"title": "FeatureNotAvailableError"
}
}
}
}
{
"openapi": "3.1.0",
"info": {
"title": "API Reference",
"version": "1.0",
"description": "foo bar"
},
"servers": [
{
"url": "https://api.example.com",
"description": "Production API"
}
],
"paths": {
"/items/{item_id}": {
"get": {
"summary": "Fetch item",
"description": "This endpoint returns an item identified by its item_id.",
"operationId": "fetch-item",
"parameters": [
{
"required": true,
"style": "simple",
"schema": {
"type": "string"
},
"name": "item_id",
"in": "path"
}
],
"responses": {
"200": {
"description": "OK",
"headers": {},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Item"
}
}
}
},
"404": {
"description": "Not Found",
"headers": {},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/404Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Item": {
"properties": {
"id": {
"type": "string",
"title": "Id"
}
},
"type": "object",
"required": [
"id"
],
"title": "Item"
},
"404Error": {
"oneOf": [
{
"$ref": "#/components/schemas/ResourceNotFoundError"
},
{
"$ref": "#/components/schemas/FeatureNotAvailableError"
}
],
"title": "404Error"
},
"ResourceNotFoundError": {
"properties": {
"type": {
"type": "string",
"const": "https://docs.example.com/reference/error-responses#404-resource-not-found",
"title": "Type"
},
"status": {
"type": "integer",
"const": 404,
"title": "Status"
},
"detail": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Detail"
},
"title": {
"type": "string",
"title": "Title"
}
},
"type": "object",
"required": [
"type",
"status",
"title"
],
"title": "ResourceNotFoundError"
},
"FeatureNotAvailableError": {
"properties": {
"type": {
"type": "string",
"const": "https://docs.example.com/reference/error-responses#404-feature-not-available",
"title": "Type"
},
"status": {
"type": "integer",
"const": 400,
"title": "Status"
},
"detail": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Detail"
},
"title": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Title"
}
},
"type": "object",
"required": [
"type",
"status"
],
"title": "FeatureNotAvailableError"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment