From 03e56b5885f64f902153bda26841cd1118ba0552 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Tue, 15 Oct 2024 09:38:26 -0700 Subject: [PATCH 1/4] fixes --- examples/OpenApi-TuttiFrutti.ps1 | 14 +- .../PetStore/Petstore-OpenApiMultiTag.ps1 | 1 - src/Private/OpenApi.ps1 | 7 +- src/Public/OAProperties.ps1 | 32 +- src/Public/OpenApi.ps1 | 31 +- .../specs/OpenApi-TuttiFrutti_3.0.3.json | 1914 +++++++++-------- .../specs/OpenApi-TuttiFrutti_3.1.0.json | 1215 +++++------ 7 files changed, 1588 insertions(+), 1626 deletions(-) diff --git a/examples/OpenApi-TuttiFrutti.ps1 b/examples/OpenApi-TuttiFrutti.ps1 index 358906a22..7527543e5 100644 --- a/examples/OpenApi-TuttiFrutti.ps1 +++ b/examples/OpenApi-TuttiFrutti.ps1 @@ -92,7 +92,6 @@ Some useful links: Add-PodeOAServerEndpoint -url '/api/v3' -Description 'default endpoint' -DefinitionTag 'v3', 'v3.1' - Add-PodeOAInfo -Title 'Swagger Petstore - OpenAPI 3.0' -Version 1.0.17 -Description $InfoDescription -TermsOfService 'http://swagger.io/terms/' -LicenseName 'Apache 2.0' ` -LicenseUrl 'http://www.apache.org/licenses/LICENSE-2.0.html' -ContactName 'API Support' -ContactEmail 'apiteam@swagger.io' -DefinitionTag 'v3' @@ -102,7 +101,7 @@ Some useful links: Enable-PodeOAViewer -Type Swagger -Path '/docs/swagger' -DefinitionTag 'v3' Enable-PodeOAViewer -Type ReDoc -Path '/docs/redoc' -DarkMode -DefinitionTag 'v3' - Enable-PodeOAViewer -Type RapiDoc -Path '/docs/rapidoc' -DarkMode -DefinitionTag 'v3' + Enable-PodeOAViewer -Type RapiDoc -Path '5/docs/rapidoc' -DarkMode -DefinitionTag 'v3' Enable-PodeOAViewer -Type StopLight -Path '/docs/stoplight' -DarkMode -DefinitionTag 'v3' Enable-PodeOAViewer -Type Explorer -Path '/docs/explorer' -DarkMode -DefinitionTag 'v3' Enable-PodeOAViewer -Type RapiPdf -Path '/docs/rapipdf' -DarkMode -DefinitionTag 'v3' @@ -303,7 +302,7 @@ Some useful links: New-PodeOAStringProperty -Name 'message' | New-PodeOAIntProperty -Name 'code'-Format Int32 | New-PodeOAObjectProperty | Add-PodeOAComponentSchema -Name 'ErrorModel' - Add-PodeRoute -PassThru -Method Get -Path '/peta/:id' -ScriptBlock { + Add-PodeRoute -PassThru -Method Get -Path '/peta/:id' -OADefinitionTag 'v3.1' -ScriptBlock { Write-PodeJsonResponse -Value (Get-Pet -Id $WebEvent.Parameters['id']) -StatusCode 200 } | Set-PodeOARouteInfo -Summary 'Find pets by ID' -Description 'Returns pets based on ID' -OperationId 'getPetsById' -PassThru | @@ -421,9 +420,9 @@ Some useful links: New-PodeOAExample -ContentType 'text/plain' -Name 'user' -Summary 'User Example in Plain text' -ExternalValue 'http://foo.bar/examples/user-example.txt' | New-PodeOAExample -ContentType '*/*' -Name 'user' -Summary 'User example in other forma' -ExternalValue 'http://foo.bar/examples/user-example.whatever' Select-PodeOADefinition -Tag 'v3' -Scriptblock { - Add-PodeRouteGroup -Path '/api/v4' -Routes { + Add-PodeRouteGroup -Path '/api/v3/private' -Routes { - Add-PodeRoute -PassThru -Method Put -Path '/pat/:petId' -ScriptBlock { + Add-PodeRoute -PassThru -Method Put,Post -Path '/pat/:petId' -ScriptBlock { $JsonPet = ConvertTo-Json $WebEvent.data if ( Update-Pet -Id $WebEvent.Parameters['petId'] -Data $JsonPet) { Write-PodeJsonResponse -Value @{} -StatusCode 200 @@ -431,7 +430,7 @@ Some useful links: else { Write-PodeJsonResponse -Value @{} -StatusCode 405 } - } | Set-PodeOARouteInfo -Summary 'Updates a pet in the store with form data' -Tags 'pet' -OperationId 'updatePasdadaetWithForm' -PassThru | + } | Set-PodeOARouteInfo -Summary 'Updates a pet in the store with form data' -Tags 'pet' -PassThru | Set-PodeOARequest -Parameters @( (New-PodeOAStringProperty -Name 'petId' -Description 'ID of pet that needs to be updated' | ConvertTo-PodeOAParameter -In Path -Required) ) -RequestBody ( @@ -441,6 +440,9 @@ Some useful links: Add-PodeOAResponse -StatusCode 200 -Description 'Pet updated.' -Content (@{ 'application/json' = '' ; 'application/xml' = '' }) -PassThru | Add-PodeOAResponse -StatusCode 405 -Description 'Method Not Allowed' -Content (@{ 'application/json' = '' ; 'application/xml' = '' }) + + + Add-PodeRoute -PassThru -Method Put -Path '/paet/:petId' -ScriptBlock { $JsonPet = ConvertTo-Json $WebEvent.data if ( Update-Pet -Id $WebEvent.Parameters['id'] -Data $JsonPet) { diff --git a/examples/PetStore/Petstore-OpenApiMultiTag.ps1 b/examples/PetStore/Petstore-OpenApiMultiTag.ps1 index 932b3b0aa..a818977da 100644 --- a/examples/PetStore/Petstore-OpenApiMultiTag.ps1 +++ b/examples/PetStore/Petstore-OpenApiMultiTag.ps1 @@ -134,7 +134,6 @@ Some useful links: Add-PodeOAServerEndpoint -url '/api/v3' -Description 'V3 Endpoint' -DefinitionTag 'v3.0.3' Add-PodeOAServerEndpoint -url '/api/v3' -Description 'V3.1 Endpoint' -DefinitionTag 'v3.1' - Add-PodeOAServerEndpoint -url '/api' -Description 'Default Endpoint' -DefinitionTag 'v3.0.3','v3.1' #OpenAPI 3.0 Enable-PodeOAViewer -Type Swagger -Path '/docs/swagger' -DefinitionTag 'v3.0.3' diff --git a/src/Private/OpenApi.ps1 b/src/Private/OpenApi.ps1 index 2acb348d3..a228fc45a 100644 --- a/src/Private/OpenApi.ps1 +++ b/src/Private/OpenApi.ps1 @@ -1149,7 +1149,12 @@ function Get-PodeOpenApiDefinitionInternal { #remove the ServerUrl part if ( $localEndpoint) { - $_route.OpenApi.Path = $_route.OpenApi.Path.replace($localEndpoint, '') + if ($_route.Path.StartsWith($localEndpoint)) { + $_route.OpenApi.Path = $_route.OpenApi.Path.replace($localEndpoint, '') + } + else { + continue + } } # do nothing if it has no responses set if ($_route.OpenApi.Responses.Count -eq 0) { diff --git a/src/Public/OAProperties.ps1 b/src/Public/OAProperties.ps1 index 8c16b8bb1..322bc2f21 100644 --- a/src/Public/OAProperties.ps1 +++ b/src/Public/OAProperties.ps1 @@ -1942,12 +1942,6 @@ If supplied, the schema will be included in a response but not in a request .PARAMETER WriteOnly If supplied, the schema will be included in a request but not in a response -.PARAMETER MinProperties -If supplied, will restrict the minimun number of properties allowed in an schema. - -.PARAMETER MaxProperties -If supplied, will restrict the maximum number of properties allowed in an schema. - .PARAMETER Array If supplied, the schema will be treated as an array of objects. @@ -2015,45 +2009,31 @@ function New-PodeOAComponentSchemaProperty { [switch] $XmlAttribute, - [Parameter( ParameterSetName = 'Array')] - [string] - $XmlItemName, - - [Parameter( ParameterSetName = 'Array')] - [switch] - $XmlWrapped, - - [Parameter(ParameterSetName = 'Array')] [object] $Example, - [Parameter(ParameterSetName = 'Array')] [switch] $Deprecated, - [Parameter(ParameterSetName = 'Array')] [switch] $Required, - [Parameter(ParameterSetName = 'Array')] [switch] $Nullable, - [Parameter(ParameterSetName = 'Array')] [switch] $ReadOnly, - [Parameter(ParameterSetName = 'Array')] [switch] $WriteOnly, - [Parameter(ParameterSetName = 'Array')] - [int] - $MinProperties, + [Parameter( ParameterSetName = 'Array')] + [string] + $XmlItemName, - [Parameter(ParameterSetName = 'Array')] - [int] - $MaxProperties, + [Parameter( ParameterSetName = 'Array')] + [switch] + $XmlWrapped, [Parameter(Mandatory = $true, ParameterSetName = 'Array')] [switch] diff --git a/src/Public/OpenApi.ps1 b/src/Public/OpenApi.ps1 index 4a07a4d29..82dccc859 100644 --- a/src/Public/OpenApi.ps1 +++ b/src/Public/OpenApi.ps1 @@ -410,6 +410,13 @@ function Add-PodeOAServerEndpoint { if ($Variables) { $lUrl.variables = $Variables } + if ($lUrl -notmatch '^(?i)https?://') { + foreach ($srv in $PodeContext.Server.OpenAPI.Definitions[$tag].servers) { + if ($srv.url -notmatch '^(?i)https?://') { + throw ("Both '{0}' and '{1}' are defined as local OpenAPI endpoints, but only one local endpoint is allowed per API definition." -f $Url, $srv.url) + } + } + } $PodeContext.Server.OpenAPI.Definitions[$tag].servers += $lUrl } } @@ -1632,16 +1639,24 @@ function Set-PodeOARouteInfo { $Route = $pipelineValue } - $DefinitionTag = Test-PodeOADefinitionTag -Tag $DefinitionTag + $defaultTag = Test-PodeOADefinitionTag -Tag $DefinitionTag foreach ($r in @($Route)) { - if ((Compare-Object -ReferenceObject $r.OpenApi.DefinitionTag -DifferenceObject $DefinitionTag).Count -ne 0) { - if ($r.OpenApi.IsDefTagConfigured ) { - # Definition Tag for a Route cannot be changed. - throw ($PodeLocale.definitionTagChangeNotAllowedExceptionMessage) + if ($DefinitionTag) { + if ((Compare-Object -ReferenceObject $r.OpenApi.DefinitionTag -DifferenceObject $DefinitionTag).Count -ne 0) { + if ($r.OpenApi.IsDefTagConfigured ) { + # Definition Tag for a Route cannot be changed. + throw ($PodeLocale.definitionTagChangeNotAllowedExceptionMessage) + } + else { + $r.OpenApi.DefinitionTag = $defaultTag + $r.OpenApi.IsDefTagConfigured = $true + } } - else { - $r.OpenApi.DefinitionTag = $DefinitionTag + } + else { + if (! $r.OpenApi.IsDefTagConfigured ) { + $r.OpenApi.DefinitionTag = $defaultTag $r.OpenApi.IsDefTagConfigured = $true } } @@ -1651,7 +1666,7 @@ function Set-PodeOARouteInfo { # OperationID:$OperationId has to be unique and cannot be applied to an array throw ($PodeLocale.operationIdMustBeUniqueForArrayExceptionMessage -f $OperationId) } - foreach ($tag in $DefinitionTag) { + foreach ($tag in $defaultTag) { if ($PodeContext.Server.OpenAPI.Definitions[$tag].hiddenComponents.operationId -ccontains $OperationId) { # OperationID:$OperationId has to be unique throw ($PodeLocale.operationIdMustBeUniqueExceptionMessage -f $OperationId) diff --git a/tests/integration/specs/OpenApi-TuttiFrutti_3.0.3.json b/tests/integration/specs/OpenApi-TuttiFrutti_3.0.3.json index 4edacfd8d..116dafdef 100644 --- a/tests/integration/specs/OpenApi-TuttiFrutti_3.0.3.json +++ b/tests/integration/specs/OpenApi-TuttiFrutti_3.0.3.json @@ -158,40 +158,60 @@ } } }, - "/user/{username}": { + "/private/paet/{petId}": { "put": { "tags": [ - "user" + "pet" ], - "summary": "Update user", - "description": "This can only be done by the logged in user.", - "operationId": "updateUser", + "summary": "Updates a pet in the store with form data", + "operationId": "updatepaet", "parameters": [ { - "description": " name that need to be updated.", - "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "examples": { + "user": { + "summary": "User Example", + "value": "http://foo.bar/examples/user-example.json" + }, + "user1": { + "summary": "User Example in XML", + "value": "http://foo.bar/examples/user-example.xml" + }, + "user2": { + "summary": "User Example in Plain text", + "value": "http://foo.bar/examples/user-example.txt" + }, + "user3": { + "summary": "User example in other forma", + "value": "http://foo.bar/examples/user-example.whatever" + } + }, + "in": "path", + "name": "petId", + "required": true, + "description": "ID of pet that needs to be updated" } ], "requestBody": { "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, "application/x-www-form-urlencoded": { "schema": { - "$ref": "#/components/schemas/User" + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Updated name of the pet" + }, + "status": { + "type": "string", + "description": "Updated status of the pet" + } + }, + "required": [ + "status" + ] } } }, @@ -199,152 +219,232 @@ }, "responses": { "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "400": { - "description": "Invalid username supplied" - }, - "404": { - "description": "User not found" + "description": "Pet updated.", + "content": { + "application/json": {}, + "application/xml": {} + } }, "405": { - "description": "Invalid Input" + "description": "Method Not Allowed", + "content": { + "application/json": {}, + "application/xml": {} + } } } - }, - "delete": { + } + }, + "/private/paet2/{petId}": { + "put": { "tags": [ - "user" + "pet" ], - "summary": "Delete user", - "description": "This can only be done by the logged in user.", - "operationId": "deleteUser", + "summary": "Updates a pet in the store with form data", + "operationId": "updatepaet2", "parameters": [ { - "description": "The name that needs to be deleted.", - "name": "username", - "required": true, + "name": "petId", "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" } ], + "requestBody": { + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "description": "user to add to the system" + }, "responses": { "200": { - "description": "Successful operation" - }, - "400": { - "description": "Invalid username supplied" + "description": "Pet updated.", + "content": { + "application/json": {}, + "application/xml": {} + } }, - "404": { - "description": "User not found" + "405": { + "description": "Method Not Allowed", + "content": { + "application/json": {}, + "application/xml": {} + } } } - }, - "get": { + } + }, + "/private/paet3/{petId}": { + "put": { "tags": [ - "user" + "pet" ], - "summary": "Get user by user name", - "description": "Get user by user name.", - "operationId": "getUserByName", + "summary": "Updates a pet in the store with form data", + "operationId": "updatepaet3", "parameters": [ { - "description": "The name that needs to be fetched. Use user1 for testing.", - "name": "username", - "required": true, + "name": "petId", "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewCat" + }, + "examples": { + "cat": { + "summary": "An example of a cat", + "value": { + "breed": "Persian", + "name": "Fluffy", + "gender": "male", + "petType": "Cat", + "color": "White" + } + }, + "dog": { + "summary": "An example of a dog with a cat's name", + "value": { + "breed": "Mixed", + "name": "Puma", + "gender": "Female", + "petType": "Dog", + "color": "Black" + } + }, + "frog-example": { + "$ref": "#/components/examples/frog-example" + } + } + } + }, + "description": "user to add to the system" + }, "responses": { "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "400": { - "description": "Invalid username supplied" + "description": "Pet updated.", + "content": { + "application/json": {}, + "application/xml": {} + } }, - "404": { - "description": "User not found" + "4XX": { + "description": "Method Not Allowed", + "content": { + "application/json": {}, + "application/xml": {} + } } } } }, - "/user_1/{username}": { + "/private/paet4/{petId}": { "put": { "tags": [ - "user" + "pet" ], - "summary": "Update user", - "description": "This can only be done by the logged in user.", - "operationId": "updateUser_1", + "summary": "Updates a pet in the store with form data", + "operationId": "updatepaet4", "parameters": [ { - "description": " name that need to be updated.", - "name": "username", - "required": true, - "schema": { - "type": "string" + "content": { + "application/json": { + "schema": { + "type": "string" + } + } }, - "in": "path" + "name": "petId", + "required": true, + "in": "path", + "description": "ID of pet that needs to be updated" } ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/StructPart" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/StructPart" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/StructPart" + "$ref": "#/components/schemas/Pet" + }, + "examples": { + "cat": { + "summary": "An example of a cat", + "value": { + "breed": "Persian", + "name": "Fluffy", + "gender": "male", + "petType": "Cat", + "color": "White" + } + }, + "dog": { + "summary": "An example of a dog with a cat's name", + "value": { + "breed": "Mixed", + "name": "Puma", + "gender": "Female", + "petType": "Dog", + "color": "Black" + } + }, + "frog-example": { + "$ref": "#/components/examples/frog-example" + } } } }, - "required": true + "description": "user to add to the system" }, "responses": { "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "400": { - "description": "Invalid username supplied" - }, - "404": { - "description": "User not found" + "description": "Pet updated.", + "content": { + "application/xml": {}, + "application/json": {} + } }, "405": { - "description": "Invalid Input" + "description": "Method Not Allowed", + "content": { + "application/json": {}, + "application/xml": {} + } } } } }, - "/userLink/{username}": { + "/private/pat/{petId}": { "put": { "tags": [ - "user" + "pet" ], - "summary": "Update user", - "description": "This can only be done by the logged in user.", - "operationId": "updateUserLink", + "summary": "Updates a pet in the store with form data", "parameters": [ { - "description": " name that need to be updated.", - "name": "username", - "required": true, + "name": "petId", "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" } ], "requestBody": { @@ -352,86 +452,172 @@ "application/json": { "schema": { "$ref": "#/components/schemas/User" + }, + "examples": { + "user": { + "summary": "User Example", + "externalValue": "http://foo.bar/examples/user-example.json" + } } }, "application/xml": { "schema": { "$ref": "#/components/schemas/User" + }, + "examples": { + "user": { + "summary": "User Example in XML", + "externalValue": "http://foo.bar/examples/user-example.xml" + } } }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/User" + "text/plain": { + "examples": { + "user": { + "summary": "User Example in Plain text", + "externalValue": "http://foo.bar/examples/user-example.txt" + } + } + }, + "\"*/*\"": { + "examples": { + "user": { + "summary": "User example in other forma", + "externalValue": "http://foo.bar/examples/user-example.whatever" + } } } }, - "required": true + "description": "user to add to the system" }, "responses": { "200": { - "description": "OK", + "description": "Pet updated.", "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" + "application/json": {}, + "application/xml": {} + } + }, + "405": { + "description": "Method Not Allowed", + "content": { + "application/json": {}, + "application/xml": {} + } + } + } + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Updates a pet in the store with form data", + "parameters": [ + { + "name": "petId", + "schema": { + "type": "string" + }, + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + }, + "examples": { + "user": { + "summary": "User Example", + "externalValue": "http://foo.bar/examples/user-example.json" } } }, - "links": { - "address": { - "operationId": "getUserByName", - "parameters": { - "username": "$request.path.username" + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + }, + "examples": { + "user": { + "summary": "User Example in XML", + "externalValue": "http://foo.bar/examples/user-example.xml" + } + } + }, + "text/plain": { + "examples": { + "user": { + "summary": "User Example in Plain text", + "externalValue": "http://foo.bar/examples/user-example.txt" + } + } + }, + "\"*/*\"": { + "examples": { + "user": { + "summary": "User example in other forma", + "externalValue": "http://foo.bar/examples/user-example.whatever" } } } }, - "400": { - "description": "Invalid username supplied" - }, - "404": { - "description": "User not found" + "description": "user to add to the system" + }, + "responses": { + "200": { + "description": "Pet updated.", + "content": { + "application/json": {}, + "application/xml": {} + } }, "405": { - "description": "Invalid Input" + "description": "Method Not Allowed", + "content": { + "application/json": {}, + "application/xml": {} + } } } } }, - "/userLinkByRef/{username}": { + "/user_1/{username}": { "put": { "tags": [ "user" ], "summary": "Update user", "description": "This can only be done by the logged in user.", - "operationId": "updateUserLinkByRef", + "operationId": "updateUser_1", "parameters": [ { - "description": " name that need to be updated.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": " name that need to be updated." } ], "requestBody": { "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/StructPart" } }, "application/xml": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/StructPart" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/StructPart" } } }, @@ -439,19 +625,7 @@ }, "responses": { "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } - } - }, - "links": { - "address2": { - "$ref": "#/components/links/address" - } - } + "$ref": "#/components/responses/UserOpSuccess" }, "400": { "description": "Invalid username supplied" @@ -465,60 +639,40 @@ } } }, - "/api/v4/paet/{petId}": { + "/user/{username}": { "put": { "tags": [ - "pet" + "user" ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatepaet", + "summary": "Update user", + "description": "This can only be done by the logged in user.", + "operationId": "updateUser", "parameters": [ { - "examples": { - "user": { - "summary": "User Example", - "value": "http://foo.bar/examples/user-example.json" - }, - "user1": { - "summary": "User Example in XML", - "value": "http://foo.bar/examples/user-example.xml" - }, - "user2": { - "summary": "User Example in Plain text", - "value": "http://foo.bar/examples/user-example.txt" - }, - "user3": { - "summary": "User example in other forma", - "value": "http://foo.bar/examples/user-example.whatever" - } + "name": "username", + "schema": { + "type": "string" }, - "name": "petId", "in": "path", "required": true, - "description": "ID of pet that needs to be updated", - "schema": { - "type": "string" - } + "description": " name that need to be updated." } ], "requestBody": { "content": { "application/x-www-form-urlencoded": { "schema": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Updated name of the pet" - }, - "status": { - "type": "string", - "description": "Updated status of the pet" - } - }, - "required": [ - "status" - ] + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" } } }, @@ -526,292 +680,213 @@ }, "responses": { "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } + "$ref": "#/components/responses/UserOpSuccess" + }, + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" }, "405": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } + "description": "Invalid Input" } } - } - }, - "/api/v4/paet2/{petId}": { - "put": { + }, + "delete": { "tags": [ - "pet" + "user" ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatepaet2", + "summary": "Delete user", + "description": "This can only be done by the logged in user.", + "operationId": "deleteUser", "parameters": [ { - "description": "ID of pet that needs to be updated", - "name": "petId", - "required": true, + "name": "username", "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "The name that needs to be deleted." } ], - "requestBody": { - "content": { - "text/plain": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "description": "user to add to the system" - }, "responses": { "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } + "description": "Successful operation" }, - "405": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" } } - } - }, - "/api/v4/paet3/{petId}": { - "put": { + }, + "get": { "tags": [ - "pet" + "user" ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatepaet3", + "summary": "Get user by user name", + "description": "Get user by user name.", + "operationId": "getUserByName", "parameters": [ { - "description": "ID of pet that needs to be updated", - "name": "petId", - "required": true, + "name": "username", "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "The name that needs to be fetched. Use user1 for testing." } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NewCat" - }, - "examples": { - "cat": { - "summary": "An example of a cat", - "value": { - "color": "White", - "name": "Fluffy", - "petType": "Cat", - "gender": "male", - "breed": "Persian" - } - }, - "dog": { - "summary": "An example of a dog with a cat's name", - "value": { - "color": "Black", - "name": "Puma", - "petType": "Dog", - "gender": "Female", - "breed": "Mixed" - } - }, - "frog-example": { - "$ref": "#/components/examples/frog-example" - } - } - } - }, - "description": "user to add to the system" - }, "responses": { "200": { - "description": "Pet updated.", - "content": { - "application/json": {}, - "application/xml": {} - } + "$ref": "#/components/responses/UserOpSuccess" }, - "4XX": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" } } } }, - "/api/v4/paet4/{petId}": { + "/userLink/{username}": { "put": { "tags": [ - "pet" + "user" ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatepaet4", + "summary": "Update user", + "description": "This can only be done by the logged in user.", + "operationId": "updateUserLink", "parameters": [ { - "description": "ID of pet that needs to be updated", - "name": "petId", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } + "name": "username", + "schema": { + "type": "string" }, + "in": "path", "required": true, - "in": "path" + "description": " name that need to be updated." } ], "requestBody": { "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, "application/json": { "schema": { - "$ref": "#/components/schemas/Pet" - }, - "examples": { - "cat": { - "summary": "An example of a cat", - "value": { - "color": "White", - "name": "Fluffy", - "petType": "Cat", - "gender": "male", - "breed": "Persian" - } - }, - "dog": { - "summary": "An example of a dog with a cat's name", - "value": { - "color": "Black", - "name": "Puma", - "petType": "Dog", - "gender": "Female", - "breed": "Mixed" - } - }, - "frog-example": { - "$ref": "#/components/examples/frog-example" - } + "$ref": "#/components/schemas/User" } } }, - "description": "user to add to the system" + "required": true }, "responses": { "200": { - "description": "Pet updated.", + "description": "OK", "content": { - "application/xml": {}, - "application/json": {} + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "links": { + "address": { + "operationId": "getUserByName", + "parameters": { + "username": "$request.path.username" + } + } } }, + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + }, "405": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } + "description": "Invalid Input" } } } }, - "/api/v4/pat/{petId}": { + "/userLinkByRef/{username}": { "put": { "tags": [ - "pet" + "user" ], - "summary": "Updates a pet in the store with form data", - "operationId": "updatePasdadaetWithForm", + "summary": "Update user", + "description": "This can only be done by the logged in user.", + "operationId": "updateUserLinkByRef", "parameters": [ { - "description": "ID of pet that needs to be updated", - "name": "petId", - "required": true, + "name": "username", "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": " name that need to be updated." } ], "requestBody": { "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/User" - }, - "examples": { - "user": { - "summary": "User Example", - "externalValue": "http://foo.bar/examples/user-example.json" - } } }, "application/xml": { "schema": { "$ref": "#/components/schemas/User" - }, - "examples": { - "user": { - "summary": "User Example in XML", - "externalValue": "http://foo.bar/examples/user-example.xml" - } - } - }, - "text/plain": { - "examples": { - "user": { - "summary": "User Example in Plain text", - "externalValue": "http://foo.bar/examples/user-example.txt" - } } }, - "\"*/*\"": { - "examples": { - "user": { - "summary": "User example in other forma", - "externalValue": "http://foo.bar/examples/user-example.whatever" - } + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" } } }, - "description": "user to add to the system" + "required": true }, "responses": { "200": { - "description": "Pet updated.", + "description": "OK", "content": { - "application/json": {}, - "application/xml": {} + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "links": { + "address2": { + "$ref": "#/components/links/address" + } } }, + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + }, "405": { - "description": "Method Not Allowed", - "content": { - "application/json": {}, - "application/xml": {} - } + "description": "Invalid Input" } } } @@ -841,49 +916,6 @@ } } }, - "get": { - "tags": [ - "pet" - ], - "summary": "Find pet by ID", - "description": "Returns a single pet.", - "operationId": "getPetById", - "parameters": [ - { - "$ref": "#/components/parameters/PetIdParam" - } - ], - "security": [ - { - "Login-OAuth2": [ - "read" - ] - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - } - } - }, "post": { "tags": [ "pet" @@ -896,20 +928,20 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { @@ -938,196 +970,26 @@ ], "responses": { "200": { - "description": "Successful operation" - }, - "400": { - "description": "Invalid ID supplied" - }, - "405": { - "description": "Invalid Input" - } - } - } - }, - "/store/order/{orderId}": { - "delete": { - "tags": [ - "store" - ], - "summary": "Delete purchase order by ID", - "description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors.", - "operationId": "deleteOrder", - "parameters": [ - { - "description": " ID of the order that needs to be deleted", - "name": "orderId", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "in": "path" - } - ], - "responses": { - "200": { - "description": "Successful operation" - }, - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Order not found" - } - } - }, - "get": { - "tags": [ - "store" - ], - "summary": "Find purchase order by ID", - "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.", - "operationId": "getOrderById", - "parameters": [ - { - "description": "ID of order that needs to be fetched", - "name": "orderId", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "in": "path" - } - ], - "servers": [ - { - "description": "ext test server", - "url": "http://ext.server.com/api/v12" - }, - { - "description": "ext test server 13", - "url": "http://ext13.server.com/api/v12" - }, - { - "description": "ext test server 14", - "url": "http://ext14.server.com/api/v12" - }, - { - "url": "/api/v3", - "description": "default endpoint" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/Order" - } - } - } - }, - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Order not found" - } - } - } - }, - "/pet/findByStatus": { - "get": { - "tags": [ - "pet" - ], - "summary": "Finds Pets by status", - "description": "Multiple status values can be provided with comma separated strings", - "operationId": "findPetsByStatus", - "parameters": [ - { - "description": "Status values that need to be considered for filter", - "name": "status", - "schema": { - "type": "string", - "default": "available", - "enum": [ - "available", - "pending", - "sold" - ] - }, - "in": "query" - } - ], - "security": [ - {}, - { - "Login-OAuth2": [ - "read" - ] - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } + "description": "Successful operation" }, "400": { - "description": "Invalid status value" + "description": "Invalid ID supplied" + }, + "405": { + "description": "Invalid Input" } } - } - }, - "/pet/findByTag": { + }, "get": { "tags": [ "pet" ], - "summary": "Finds Pets by tags", - "description": "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId": "findPetsByTags", + "summary": "Find pet by ID", + "description": "Returns a single pet.", + "operationId": "getPetById", "parameters": [ { - "description": "Tags to filter by", - "name": "tag", - "explode": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "in": "query" + "$ref": "#/components/parameters/PetIdParam" } ], "security": [ @@ -1135,21 +997,18 @@ "Login-OAuth2": [ "read" ] - }, - { - "api_key": [] } ], "responses": { "200": { "description": "Successful operation", "content": { - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } }, - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } @@ -1157,163 +1016,109 @@ } }, "400": { - "description": "Invalid status value" + "description": "Invalid ID supplied" }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } + "404": { + "description": "Pet not found" } } } }, - "/store/inventory": { - "get": { + "/store/order/{orderId}": { + "delete": { "tags": [ "store" ], - "summary": "Returns pet inventories by status", - "description": "Returns a map of status codes to quantities", - "operationId": "getInventory", + "summary": "Delete purchase order by ID", + "description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors.", + "operationId": "deleteOrder", + "parameters": [ + { + "name": "orderId", + "schema": { + "type": "integer", + "format": "int64" + }, + "in": "path", + "required": true, + "description": " ID of the order that needs to be deleted" + } + ], "responses": { "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "none": { - "type": "string" - } - } - } - } - } + "description": "Successful operation" + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" } } - } - }, - "/user/login": { + }, "get": { "tags": [ - "user" + "store" ], - "summary": "Logs user into the system.", - "description": "Logs user into the system.", - "operationId": "loginUser", + "summary": "Find purchase order by ID", + "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.", + "operationId": "getOrderById", "parameters": [ { - "description": "The user name for login", - "name": "username", + "name": "orderId", "schema": { - "type": "string" + "type": "integer", + "format": "int64" }, - "in": "query" + "in": "path", + "required": true, + "description": "ID of order that needs to be fetched" + } + ], + "servers": [ + { + "description": "ext test server", + "url": "http://ext.server.com/api/v12" }, { - "description": "The password for login in clear text", - "name": "password", - "schema": { - "type": "string", - "format": "password" - }, - "in": "query" + "description": "ext test server 13", + "url": "http://ext13.server.com/api/v12" + }, + { + "description": "ext test server 14", + "url": "http://ext14.server.com/api/v12" + }, + { + "url": "/api/v3", + "description": "default endpoint" } ], "responses": { "200": { "description": "Successful operation", - "headers": { - "X-Rate-Limit": { - "$ref": "#/components/headers/X-Rate-Limit" - }, - "X-Expires-After": { - "$ref": "#/components/headers/X-Expires-After" - } - }, "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, "application/xml": { "schema": { - "type": "string" + "$ref": "#/components/schemas/Order" } }, "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/Order" } } } }, "400": { - "description": "Invalid username/password supplied" - } - } - } - }, - "/user/logout": { - "get": { - "tags": [ - "user" - ], - "summary": "Logs out current logged in user session.", - "description": "Logs out current logged in user session.", - "operationId": "logoutUser", - "responses": { - "200": { - "description": "Successful operation" - } - } - } - }, - "/peta/{id}": { - "get": { - "summary": "Find pets by ID", - "description": "Returns pets based on ID", - "operationId": "getPetsById", - "parameters": [ - { - "style": "simple", - "name": "id", - "in": "path", - "required": true, - "description": "ID of pet to use", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "\"*/*\"": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } + "description": "Invalid ID supplied" }, - "default": { - "description": "error payload", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/ApiResponse" - } - } - } + "404": { + "description": "Order not found" } } } @@ -1328,22 +1133,22 @@ "operationId": "uploadFile2", "parameters": [ { - "description": "ID of pet that needs to be updated", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" }, { - "description": "Additional Metadata", "name": "additionalMetadata", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Additional Metadata" } ], "requestBody": { @@ -1381,8 +1186,8 @@ "X-Rate-Limit-Reset": { "description": "The number of seconds left in the current period", "schema": { - "type": "integer", - "maximum": 3 + "maximum": 3, + "type": "integer" } } }, @@ -1408,22 +1213,22 @@ "operationId": "uploadFileOctet", "parameters": [ { - "description": "ID of pet that needs to be updated", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" }, { - "description": "Additional Metadata", "name": "additionalMetadata", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Additional Metadata" } ], "requestBody": { @@ -1464,22 +1269,22 @@ "operationId": "uploadFilemulti", "parameters": [ { - "description": "ID of pet that needs to be updated", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" }, { - "description": "Additional Metadata", "name": "additionalMetadata", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Additional Metadata" } ], "requestBody": { @@ -1533,20 +1338,20 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { @@ -1601,20 +1406,20 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { @@ -1681,25 +1486,47 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { "content": { "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "address": { + "type": "object", + "properties": {} + }, + "historyMetadata": { + "type": "object", + "description": "metadata in XML format", + "properties": {} + }, + "profileImage": { + "type": "string", + "format": "binary" + } + } + }, "encoding": { "historyMetadata": { "contentType": "application/xml; charset=utf-8" @@ -1710,47 +1537,25 @@ "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", "schema": { + "maximum": 3, + "default": 3, + "type": "integer", "enum": [ 1, 2, 3 - ], - "default": 3, - "type": "integer", - "maximum": 3 + ] } }, "X-Rate-Limit-Reset": { "description": "The number of seconds left in the current period", "schema": { - "type": "integer", - "minimum": 2 + "minimum": 2, + "type": "integer" } } } } - }, - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "address": { - "type": "object", - "properties": {} - }, - "historyMetadata": { - "type": "object", - "description": "metadata in XML format", - "properties": {} - }, - "profileImage": { - "type": "string", - "format": "binary" - } - } } } } @@ -1891,22 +1696,293 @@ "tags": [ "pet" ], - "summary": "Add a new pet to the store", - "description": "Add a new pet to the store", - "operationId": "petcallbackReference", - "requestBody": { - "$ref": "#/components/requestBodies/PetBodySchema" - }, - "callbacks": { - "test1": { - "$ref": "#/components/callbacks/test" + "summary": "Add a new pet to the store", + "description": "Add a new pet to the store", + "operationId": "petcallbackReference", + "requestBody": { + "$ref": "#/components/requestBodies/PetBodySchema" + }, + "callbacks": { + "test1": { + "$ref": "#/components/callbacks/test" + } + }, + "security": [ + { + "Login-OAuth2": [ + "write" + ] + } + ], + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "405": { + "description": "Validation exception", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "result": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/store/order": { + "post": { + "deprecated": true, + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "description": "Place a new order in the store", + "operationId": "placeOrder", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "405": { + "description": "Invalid Input" + } + } + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user.", + "description": "This can only be done by the logged in user.", + "operationId": "createUser", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserOpSuccess" + }, + "405": { + "description": "Invalid Input", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "result": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array.", + "description": "Creates list of users with given input array.", + "operationId": "createUsersWithListInput", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserOpSuccess" + }, + "405": { + "description": "Invalid Input" + } + } + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "schema": { + "type": "string", + "default": "available", + "enum": [ + "available", + "pending", + "sold" + ] + }, + "in": "query", + "description": "Status values that need to be considered for filter" + } + ], + "security": [ + { + "Login-OAuth2": [ + "read" + ] + }, + {} + ], + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "400": { + "description": "Invalid status value" + } + } + } + }, + "/pet/findByTag": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tag", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "in": "query", + "explode": true, + "description": "Tags to filter by" } - }, + ], "security": [ { "Login-OAuth2": [ - "write" + "read" ] + }, + { + "api_key": [] } ], "responses": { @@ -1925,20 +2001,15 @@ } } }, - "405": { - "description": "Validation exception", + "400": { + "description": "Invalid status value" + }, + "default": { + "description": "Unexpected error", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "result": { - "type": "string" - }, - "message": { - "type": "string" - } - } + "$ref": "#/components/schemas/ErrorModel" } } } @@ -1946,151 +2017,98 @@ } } }, - "/store/order": { - "post": { - "deprecated": true, + "/store/inventory": { + "get": { "tags": [ "store" ], - "summary": "Place an order for a pet", - "description": "Place a new order in the store", - "operationId": "placeOrder", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/Order" - } - } - }, - "required": true - }, + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", "responses": { "200": { "description": "Successful operation", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Order" + "type": "object", + "properties": { + "none": { + "type": "string" + } + } } } } - }, - "405": { - "description": "Invalid Input" } } } }, - "/user": { - "post": { + "/user/login": { + "get": { "tags": [ "user" ], - "summary": "Create user.", - "description": "This can only be done by the logged in user.", - "operationId": "createUser", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - } + "summary": "Logs user into the system.", + "description": "Logs user into the system.", + "operationId": "loginUser", + "parameters": [ + { + "name": "username", + "schema": { + "type": "string" }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/User" - } - } + "in": "query", + "description": "The user name for login" }, - "required": true - }, + { + "name": "password", + "schema": { + "type": "string", + "format": "password" + }, + "in": "query", + "description": "The password for login in clear text" + } + ], "responses": { "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "405": { - "description": "Invalid Input", + "description": "Successful operation", + "headers": { + "X-Rate-Limit": { + "$ref": "#/components/headers/X-Rate-Limit" + }, + "X-Expires-After": { + "$ref": "#/components/headers/X-Expires-After" + } + }, "content": { + "application/xml": { + "schema": { + "type": "string" + } + }, "application/json": { "schema": { - "type": "object", - "properties": { - "result": { - "type": "string" - }, - "message": { - "type": "string" - } - } + "type": "string" } } } + }, + "400": { + "description": "Invalid username/password supplied" } } } }, - "/user/createWithList": { - "post": { + "/user/logout": { + "get": { "tags": [ "user" ], - "summary": "Creates list of users with given input array.", - "description": "Creates list of users with given input array.", - "operationId": "createUsersWithListInput", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/User" - } - } - }, - "required": true - }, - "responses": { - "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "405": { - "description": "Invalid Input" - } - } - } - }, - "/close": { - "post": { - "summary": "Shutdown the server", + "summary": "Logs out current logged in user session.", + "description": "Logs out current logged in user session.", + "operationId": "logoutUser", "responses": { "200": { "description": "Successful operation" @@ -2108,14 +2126,14 @@ "operationId": "getOrderExternalById", "parameters": [ { - "description": "ID of order that needs to be fetched", "name": "orderId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of order that needs to be fetched" } ], "servers": [ @@ -2136,7 +2154,7 @@ "200": { "description": "Successful operation", "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/Order" } @@ -2146,7 +2164,7 @@ "$ref": "#/components/schemas/Order" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { "$ref": "#/components/schemas/Order" } @@ -2529,6 +2547,7 @@ "$ref": "#/components/schemas/Pet2" }, { + "type": "object", "properties": { "huntingSkill": { "type": "string", @@ -2542,7 +2561,6 @@ ] } }, - "type": "object", "required": [ "huntingSkill" ] @@ -2556,6 +2574,7 @@ "$ref": "#/components/schemas/Pet2" }, { + "type": "object", "properties": { "packSize": { "type": "integer", @@ -2564,7 +2583,6 @@ "format": "int32" } }, - "type": "object", "required": [ "packSize" ] @@ -2578,12 +2596,12 @@ "$ref": "#/components/schemas/Pet" }, { + "type": "object", "properties": { "rootCause": { "type": "string" } }, - "type": "object", "required": [ "rootCause" ] @@ -2610,6 +2628,7 @@ "$ref": "#/components/schemas/Pet" }, { + "type": "object", "properties": { "huntingSkill": { "type": "string", @@ -2621,8 +2640,7 @@ "aggressive" ] } - }, - "type": "object" + } } ] }, @@ -2715,32 +2733,32 @@ }, "parameters": { "PetIdParam": { - "description": "ID of the pet", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of the pet" } }, "examples": { "frog-example": { "summary": "An example of a frog with a cat's name", "value": { - "color": "Lion", + "breed": "Mantella Baroni", "name": "Jaguar", - "petType": "Panthera", "gender": "Male", - "breed": "Mantella Baroni" + "petType": "Panthera", + "color": "Lion" } } }, "requestBodies": { "PetBodySchema": { "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pets" } @@ -2750,7 +2768,7 @@ "$ref": "#/components/schemas/Pets" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pets" } @@ -2832,23 +2850,9 @@ } }, "securitySchemes": { - "Login": { - "scheme": "basic", - "type": "http" - }, - "LoginApiKey": { - "type": "apiKey", - "in": "header", - "name": "X-API-KEY" - }, - "api_key": { - "type": "apiKey", - "in": "header", - "name": "api_key" - }, "Jwt": { - "scheme": "bearer", - "type": "http" + "type": "http", + "scheme": "bearer" }, "Login-OAuth2": { "type": "oauth2", @@ -2862,6 +2866,20 @@ } } } + }, + "LoginApiKey": { + "type": "apiKey", + "in": "header", + "name": "X-API-KEY" + }, + "Login": { + "type": "http", + "scheme": "basic" + }, + "api_key": { + "type": "apiKey", + "in": "header", + "name": "api_key" } } } diff --git a/tests/integration/specs/OpenApi-TuttiFrutti_3.1.0.json b/tests/integration/specs/OpenApi-TuttiFrutti_3.1.0.json index c3a5d1de2..49c90cedf 100644 --- a/tests/integration/specs/OpenApi-TuttiFrutti_3.1.0.json +++ b/tests/integration/specs/OpenApi-TuttiFrutti_3.1.0.json @@ -171,40 +171,40 @@ } } }, - "/user/{username}": { + "/user_1/{username}": { "put": { "tags": [ "user" ], "summary": "Update user", "description": "This can only be done by the logged in user.", - "operationId": "updateUser", + "operationId": "updateUser_1", "parameters": [ { - "description": " name that need to be updated.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": " name that need to be updated." } ], "requestBody": { "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/StructPart" } }, "application/xml": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/StructPart" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/StructPart" } } }, @@ -224,58 +224,83 @@ "description": "Invalid Input" } } - }, - "delete": { + } + }, + "/user/{username}": { + "put": { "tags": [ "user" ], - "summary": "Delete user", + "summary": "Update user", "description": "This can only be done by the logged in user.", - "operationId": "deleteUser", + "operationId": "updateUser", "parameters": [ { - "description": "The name that needs to be deleted.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": " name that need to be updated." } ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, "responses": { "200": { - "description": "Successful operation" + "$ref": "#/components/responses/UserOpSuccess" }, "400": { "description": "Invalid username supplied" }, "404": { "description": "User not found" + }, + "405": { + "description": "Invalid Input" } } }, - "get": { + "delete": { "tags": [ "user" ], - "summary": "Get user by user name", - "description": "Get user by user name.", - "operationId": "getUserByName", + "summary": "Delete user", + "description": "This can only be done by the logged in user.", + "operationId": "deleteUser", "parameters": [ { - "description": "The name that needs to be fetched. Use user1 for testing.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "The name that needs to be deleted." } ], "responses": { "200": { - "$ref": "#/components/responses/UserOpSuccess" + "description": "Successful operation" }, "400": { "description": "Invalid username supplied" @@ -284,47 +309,25 @@ "description": "User not found" } } - } - }, - "/user_1/{username}": { - "put": { + }, + "get": { "tags": [ "user" ], - "summary": "Update user", - "description": "This can only be done by the logged in user.", - "operationId": "updateUser_1", + "summary": "Get user by user name", + "description": "Get user by user name.", + "operationId": "getUserByName", "parameters": [ { - "description": " name that need to be updated.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": "The name that needs to be fetched. Use user1 for testing." } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/StructPart" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/StructPart" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/StructPart" - } - } - }, - "required": true - }, "responses": { "200": { "$ref": "#/components/responses/UserOpSuccess" @@ -334,9 +337,6 @@ }, "404": { "description": "User not found" - }, - "405": { - "description": "Invalid Input" } } } @@ -351,18 +351,18 @@ "operationId": "updateUserLink", "parameters": [ { - "description": " name that need to be updated.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": " name that need to be updated." } ], "requestBody": { "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/User" } @@ -372,7 +372,7 @@ "$ref": "#/components/schemas/User" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { "$ref": "#/components/schemas/User" } @@ -421,18 +421,18 @@ "operationId": "updateUserLinkByRef", "parameters": [ { - "description": " name that need to be updated.", "name": "username", - "required": true, "schema": { "type": "string" }, - "in": "path" + "in": "path", + "required": true, + "description": " name that need to be updated." } ], "requestBody": { "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/User" } @@ -442,7 +442,7 @@ "$ref": "#/components/schemas/User" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { "$ref": "#/components/schemas/User" } @@ -503,49 +503,6 @@ } } }, - "get": { - "tags": [ - "pet" - ], - "summary": "Find pet by ID", - "description": "Returns a single pet.", - "operationId": "getPetById", - "parameters": [ - { - "$ref": "#/components/parameters/PetIdParam" - } - ], - "security": [ - { - "Login-OAuth2": [ - "read" - ] - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - } - } - }, "post": { "tags": [ "pet" @@ -558,20 +515,20 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { @@ -611,6 +568,49 @@ "description": "Invalid Input" } } + }, + "get": { + "tags": [ + "pet" + ], + "summary": "Find pet by ID", + "description": "Returns a single pet.", + "operationId": "getPetById", + "parameters": [ + { + "$ref": "#/components/parameters/PetIdParam" + } + ], + "security": [ + { + "Login-OAuth2": [ + "read" + ] + } + ], + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + } + } } }, "/store/order/{orderId}": { @@ -623,14 +623,14 @@ "operationId": "deleteOrder", "parameters": [ { - "description": " ID of the order that needs to be deleted", "name": "orderId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": " ID of the order that needs to be deleted" } ], "responses": { @@ -654,14 +654,14 @@ "operationId": "getOrderById", "parameters": [ { - "description": "ID of order that needs to be fetched", "name": "orderId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of order that needs to be fetched" } ], "servers": [ @@ -686,7 +686,7 @@ "200": { "description": "Successful operation", "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/Order" } @@ -696,7 +696,7 @@ "$ref": "#/components/schemas/Order" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { "$ref": "#/components/schemas/Order" } @@ -712,306 +712,32 @@ } } }, - "/pet/findByStatus": { - "get": { + "/pet/{petId}/uploadImage2": { + "post": { "tags": [ "pet" ], - "summary": "Finds Pets by status", - "description": "Multiple status values can be provided with comma separated strings", - "operationId": "findPetsByStatus", + "summary": "Uploads an image", + "description": "Updates a pet in the store with a new image", + "operationId": "uploadFile2", "parameters": [ { - "description": "Status values that need to be considered for filter", - "name": "status", + "name": "petId", "schema": { - "type": "string", - "default": "available", - "enum": [ - "available", - "pending", - "sold" - ] + "type": "integer", + "format": "int64" }, - "in": "query" - } - ], - "security": [ - {}, + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" + }, { - "Login-OAuth2": [ - "read" - ] - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "400": { - "description": "Invalid status value" - } - } - } - }, - "/pet/findByTag": { - "get": { - "tags": [ - "pet" - ], - "summary": "Finds Pets by tags", - "description": "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId": "findPetsByTags", - "parameters": [ - { - "description": "Tags to filter by", - "name": "tag", - "explode": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "in": "query" - } - ], - "security": [ - { - "Login-OAuth2": [ - "read" - ] - }, - { - "api_key": [] - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - }, - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "400": { - "description": "Invalid status value" - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorModel" - } - } - } - } - } - } - }, - "/store/inventory": { - "get": { - "tags": [ - "store" - ], - "summary": "Returns pet inventories by status", - "description": "Returns a map of status codes to quantities", - "operationId": "getInventory", - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "type": [ - "object" - ], - "properties": { - "none": { - "type": [ - "string" - ] - } - } - } - } - } - } - } - } - }, - "/user/login": { - "get": { - "tags": [ - "user" - ], - "summary": "Logs user into the system.", - "description": "Logs user into the system.", - "operationId": "loginUser", - "parameters": [ - { - "description": "The user name for login", - "name": "username", - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "description": "The password for login in clear text", - "name": "password", - "schema": { - "type": "string", - "format": "password" - }, - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "headers": { - "X-Rate-Limit": { - "$ref": "#/components/headers/X-Rate-Limit" - }, - "X-Expires-After": { - "$ref": "#/components/headers/X-Expires-After" - } - }, - "content": { - "application/xml": { - "schema": { - "type": "string" - } - }, - "application/json": { - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Invalid username/password supplied" - } - } - } - }, - "/user/logout": { - "get": { - "tags": [ - "user" - ], - "summary": "Logs out current logged in user session.", - "description": "Logs out current logged in user session.", - "operationId": "logoutUser", - "responses": { - "200": { - "description": "Successful operation" - } - } - } - }, - "/peta/{id}": { - "get": { - "summary": "Find pets by ID", - "description": "Returns pets based on ID", - "operationId": "getPetsById", - "parameters": [ - { - "style": "simple", - "name": "id", - "in": "path", - "required": true, - "description": "ID of pet to use", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "\"*/*\"": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "error payload", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/ApiResponse" - } - } - } - } - } - } - }, - "/pet/{petId}/uploadImage2": { - "post": { - "tags": [ - "pet" - ], - "summary": "Uploads an image", - "description": "Updates a pet in the store with a new image", - "operationId": "uploadFile2", - "parameters": [ - { - "description": "ID of pet that needs to be updated", - "name": "petId", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "in": "path" - }, - { - "description": "Additional Metadata", - "name": "additionalMetadata", - "schema": { - "type": "string" - }, - "in": "query" + "name": "additionalMetadata", + "schema": { + "type": "string" + }, + "in": "query", + "description": "Additional Metadata" } ], "requestBody": { @@ -1053,8 +779,8 @@ "X-Rate-Limit-Reset": { "description": "The number of seconds left in the current period", "schema": { - "type": "integer", - "maximum": 3 + "maximum": 3, + "type": "integer" } } }, @@ -1084,22 +810,22 @@ "operationId": "uploadFileOctet", "parameters": [ { - "description": "ID of pet that needs to be updated", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" }, { - "description": "Additional Metadata", "name": "additionalMetadata", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Additional Metadata" } ], "requestBody": { @@ -1140,22 +866,22 @@ "operationId": "uploadFilemulti", "parameters": [ { - "description": "ID of pet that needs to be updated", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet that needs to be updated" }, { - "description": "Additional Metadata", "name": "additionalMetadata", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Additional Metadata" } ], "requestBody": { @@ -1215,20 +941,20 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { @@ -1289,20 +1015,20 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { @@ -1377,55 +1103,25 @@ "$ref": "#/components/parameters/PetIdParam" }, { - "description": "Name of pet that needs to be updated", "name": "name", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Name of pet that needs to be updated" }, { - "description": "Status of pet that needs to be updated", "name": "status", "schema": { "type": "string" }, - "in": "query" + "in": "query", + "description": "Status of pet that needs to be updated" } ], "requestBody": { "content": { "multipart/form-data": { - "encoding": { - "historyMetadata": { - "contentType": "application/xml; charset=utf-8" - }, - "profileImage": { - "contentType": "image/png, image/jpeg", - "headers": { - "X-Rate-Limit-Limit": { - "description": "The number of allowed requests in the current period", - "schema": { - "enum": [ - 1, - 2, - 3 - ], - "default": 3, - "type": "integer", - "maximum": 3 - } - }, - "X-Rate-Limit-Reset": { - "description": "The number of seconds left in the current period", - "schema": { - "type": "integer", - "minimum": 2 - } - } - } - } - }, "schema": { "type": [ "object" @@ -1457,6 +1153,36 @@ "format": "binary" } } + }, + "encoding": { + "historyMetadata": { + "contentType": "application/xml; charset=utf-8" + }, + "profileImage": { + "contentType": "image/png, image/jpeg", + "headers": { + "X-Rate-Limit-Limit": { + "description": "The number of allowed requests in the current period", + "schema": { + "maximum": 3, + "default": 3, + "type": "integer", + "enum": [ + 1, + 2, + 3 + ] + } + }, + "X-Rate-Limit-Reset": { + "description": "The number of seconds left in the current period", + "schema": { + "minimum": 2, + "type": "integer" + } + } + } + } } } } @@ -1617,12 +1343,295 @@ "test1": { "$ref": "#/components/callbacks/test" } - }, + }, + "security": [ + { + "Login-OAuth2": [ + "write" + ] + } + ], + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "405": { + "description": "Validation exception", + "content": { + "application/json": { + "schema": { + "type": [ + "object" + ], + "properties": { + "result": { + "type": [ + "string" + ] + }, + "message": { + "type": [ + "string" + ] + } + } + } + } + } + } + } + } + }, + "/store/order": { + "post": { + "deprecated": true, + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "description": "Place a new order in the store", + "operationId": "placeOrder", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "405": { + "description": "Invalid Input" + } + } + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user.", + "description": "This can only be done by the logged in user.", + "operationId": "createUser", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserOpSuccess" + }, + "405": { + "description": "Invalid Input", + "content": { + "application/json": { + "schema": { + "type": [ + "object" + ], + "properties": { + "result": { + "type": [ + "string" + ] + }, + "message": { + "type": [ + "string" + ] + } + } + } + } + } + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array.", + "description": "Creates list of users with given input array.", + "operationId": "createUsersWithListInput", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserOpSuccess" + }, + "405": { + "description": "Invalid Input" + } + } + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "schema": { + "type": "string", + "default": "available", + "enum": [ + "available", + "pending", + "sold" + ] + }, + "in": "query", + "description": "Status values that need to be considered for filter" + } + ], + "security": [ + { + "Login-OAuth2": [ + "read" + ] + }, + {} + ], + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "400": { + "description": "Invalid status value" + } + } + } + }, + "/pet/findByTag": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tag", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "in": "query", + "explode": true, + "description": "Tags to filter by" + } + ], "security": [ { "Login-OAuth2": [ - "write" + "read" ] + }, + { + "api_key": [] } ], "responses": { @@ -1641,26 +1650,15 @@ } } }, - "405": { - "description": "Validation exception", + "400": { + "description": "Invalid status value" + }, + "default": { + "description": "Unexpected error", "content": { "application/json": { "schema": { - "type": [ - "object" - ], - "properties": { - "result": { - "type": [ - "string" - ] - }, - "message": { - "type": [ - "string" - ] - } - } + "$ref": "#/components/schemas/ErrorModel" } } } @@ -1668,91 +1666,17 @@ } } }, - "/store/order": { - "post": { - "deprecated": true, + "/store/inventory": { + "get": { "tags": [ "store" ], - "summary": "Place an order for a pet", - "description": "Place a new order in the store", - "operationId": "placeOrder", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/Order" - } - } - }, - "required": true - }, + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", "responses": { "200": { "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Order" - } - } - } - }, - "405": { - "description": "Invalid Input" - } - } - } - }, - "/user": { - "post": { - "tags": [ - "user" - ], - "summary": "Create user.", - "description": "This can only be done by the logged in user.", - "operationId": "createUser", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" - } - }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/User" - } - } - }, - "required": true - }, - "responses": { - "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "405": { - "description": "Invalid Input", "content": { "application/json": { "schema": { @@ -1760,12 +1684,7 @@ "object" ], "properties": { - "result": { - "type": [ - "string" - ] - }, - "message": { + "none": { "type": [ "string" ] @@ -1778,47 +1697,71 @@ } } }, - "/user/createWithList": { - "post": { + "/user/login": { + "get": { "tags": [ "user" ], - "summary": "Creates list of users with given input array.", - "description": "Creates list of users with given input array.", - "operationId": "createUsersWithListInput", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } + "summary": "Logs user into the system.", + "description": "Logs user into the system.", + "operationId": "loginUser", + "parameters": [ + { + "name": "username", + "schema": { + "type": "string" }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/User" + "in": "query", + "description": "The user name for login" + }, + { + "name": "password", + "schema": { + "type": "string", + "format": "password" + }, + "in": "query", + "description": "The password for login in clear text" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "headers": { + "X-Rate-Limit": { + "$ref": "#/components/headers/X-Rate-Limit" + }, + "X-Expires-After": { + "$ref": "#/components/headers/X-Expires-After" } }, - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/User" + "content": { + "application/xml": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } } } }, - "required": true - }, - "responses": { - "200": { - "$ref": "#/components/responses/UserOpSuccess" - }, - "405": { - "description": "Invalid Input" + "400": { + "description": "Invalid username/password supplied" } } } }, - "/close": { - "post": { - "summary": "Shutdown the server", + "/user/logout": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs out current logged in user session.", + "description": "Logs out current logged in user session.", + "operationId": "logoutUser", "responses": { "200": { "description": "Successful operation" @@ -1836,14 +1779,14 @@ "operationId": "getOrderExternalById", "parameters": [ { - "description": "ID of order that needs to be fetched", "name": "orderId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of order that needs to be fetched" } ], "servers": [ @@ -1864,7 +1807,7 @@ "200": { "description": "Successful operation", "content": { - "application/json": { + "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/Order" } @@ -1874,7 +1817,7 @@ "$ref": "#/components/schemas/Order" } }, - "application/x-www-form-urlencoded": { + "application/json": { "schema": { "$ref": "#/components/schemas/Order" } @@ -2420,6 +2363,7 @@ "$ref": "#/components/schemas/Pet2" }, { + "type": "object", "properties": { "huntingSkill": { "type": [ @@ -2435,7 +2379,6 @@ ] } }, - "type": "object", "required": [ "huntingSkill" ] @@ -2449,6 +2392,7 @@ "$ref": "#/components/schemas/Pet2" }, { + "type": "object", "properties": { "packSize": { "type": [ @@ -2459,7 +2403,6 @@ "format": "int32" } }, - "type": "object", "required": [ "packSize" ] @@ -2473,6 +2416,7 @@ "$ref": "#/components/schemas/Pet" }, { + "type": "object", "properties": { "rootCause": { "type": [ @@ -2480,7 +2424,6 @@ ] } }, - "type": "object", "required": [ "rootCause" ] @@ -2511,6 +2454,7 @@ "$ref": "#/components/schemas/Pet" }, { + "type": "object", "properties": { "huntingSkill": { "type": [ @@ -2524,8 +2468,7 @@ "aggressive" ] } - }, - "type": "object" + } } ] }, @@ -2640,20 +2583,20 @@ }, "parameters": { "PetIdParam": { - "description": "ID of the pet", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of the pet" } }, "requestBodies": { "PetBodySchema": { "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pets" } @@ -2663,7 +2606,7 @@ "$ref": "#/components/schemas/Pets" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pets" } @@ -2761,14 +2704,14 @@ "operationId": "getPetByIdWithRef", "parameters": [ { - "description": "ID of pet to return", "name": "petId", - "required": true, "schema": { "type": "integer", "format": "int64" }, - "in": "path" + "in": "path", + "required": true, + "description": "ID of pet to return" } ], "responses": { @@ -2801,23 +2744,9 @@ } }, "securitySchemes": { - "Login": { - "scheme": "basic", - "type": "http" - }, - "LoginApiKey": { - "type": "apiKey", - "in": "header", - "name": "X-API-KEY" - }, - "api_key": { - "type": "apiKey", - "in": "header", - "name": "api_key" - }, "Jwt": { - "scheme": "bearer", - "type": "http" + "type": "http", + "scheme": "bearer" }, "Login-OAuth2": { "type": "oauth2", @@ -2831,6 +2760,20 @@ } } } + }, + "LoginApiKey": { + "type": "apiKey", + "in": "header", + "name": "X-API-KEY" + }, + "Login": { + "type": "http", + "scheme": "basic" + }, + "api_key": { + "type": "apiKey", + "in": "header", + "name": "api_key" } } } From 2125c9b79061c5470f6ff4f34c7efb81f2046a5f Mon Sep 17 00:00:00 2001 From: mdaneri Date: Tue, 15 Oct 2024 10:03:26 -0700 Subject: [PATCH 2/4] Update OpenApi.Tests.ps1 --- tests/unit/OpenApi.Tests.ps1 | 40 +++++++++--------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/tests/unit/OpenApi.Tests.ps1 b/tests/unit/OpenApi.Tests.ps1 index 4f4a26bbf..4f16f79e4 100644 --- a/tests/unit/OpenApi.Tests.ps1 +++ b/tests/unit/OpenApi.Tests.ps1 @@ -1821,7 +1821,7 @@ Describe 'OpenApi' { } It 'ArrayNoSwitchesUniqueItems' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -Array -MinItems 2 -MaxItems 4 -UniqueItems $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 1 @@ -1829,8 +1829,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result.array | Should -BeTrue $result.uniqueItems | Should -BeTrue @@ -1839,7 +1837,7 @@ Describe 'OpenApi' { } It 'ArrayDeprecatedUniqueItems' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -Deprecated -Array -MinItems 2 -MaxItems 4 -UniqueItems $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 1 @@ -1847,8 +1845,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result.deprecated | Should -Be $true $result.array | Should -BeTrue @@ -1857,7 +1853,7 @@ Describe 'OpenApi' { $result.maxItems | Should -BeTrue } It 'ArrayNullableUniqueItems' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -Nullable -Array -MinItems 2 -MaxItems 4 -UniqueItems $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 2 @@ -1865,8 +1861,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result['nullable'] | Should -Be $true $result.array | Should -BeTrue @@ -1875,7 +1869,7 @@ Describe 'OpenApi' { $result.maxItems | Should -BeTrue } It 'ArrayWriteOnlyUniqueItems' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -WriteOnly -Array -MinItems 2 -MaxItems 4 -UniqueItems $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 2 @@ -1883,8 +1877,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result['writeOnly'] | Should -Be $true $result.array | Should -BeTrue @@ -1893,7 +1885,7 @@ Describe 'OpenApi' { $result.maxItems | Should -BeTrue } It 'ArrayReadOnlyUniqueItems' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -ReadOnly -Array -MinItems 2 -MaxItems 4 -UniqueItems $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 2 @@ -1901,8 +1893,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result['readOnly'] | Should -Be $true $result.array | Should -BeTrue @@ -1912,7 +1902,7 @@ Describe 'OpenApi' { } It 'ArrayNoSwitches' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -Array -MinItems 2 -MaxItems 4 $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 1 @@ -1920,8 +1910,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result.array | Should -BeTrue $result.minItems | Should -BeTrue @@ -1929,7 +1917,7 @@ Describe 'OpenApi' { } It 'ArrayDeprecated' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -Deprecated -Array -MinItems 2 -MaxItems 4 $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 1 @@ -1937,8 +1925,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result.deprecated | Should -Be $true $result.array | Should -BeTrue @@ -1946,7 +1932,7 @@ Describe 'OpenApi' { $result.maxItems | Should -BeTrue } It 'ArrayNullable' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -Nullable -Array -MinItems 2 -MaxItems 4 $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 2 @@ -1954,8 +1940,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result['nullable'] | Should -Be $true $result.array | Should -BeTrue @@ -1963,7 +1947,7 @@ Describe 'OpenApi' { $result.maxItems | Should -BeTrue } It 'ArrayWriteOnly' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -WriteOnly -Array -MinItems 2 -MaxItems 4 $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 2 @@ -1971,8 +1955,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result['writeOnly'] | Should -Be $true $result.array | Should -BeTrue @@ -1980,7 +1962,7 @@ Describe 'OpenApi' { $result.maxItems | Should -BeTrue } It 'ArrayReadOnly' { - $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' -MinProperties 1 -MaxProperties 2 ` + $result = New-PodeOASchemaProperty -Name 'testSchema' -Description 'Test for New-PodeOASchemaProperty' -Reference 'Cat' ` -Example 'Example for New-PodeOASchemaProperty' -ReadOnly -Array -MinItems 2 -MaxItems 4 $result | Should -Not -BeNullOrEmpty #$result.Count | Should -Be 2 @@ -1988,8 +1970,6 @@ Describe 'OpenApi' { $result.name | Should -Be 'testSchema' $result.schema | Should -Be 'Cat' $result.description | Should -Be 'Test for New-PodeOASchemaProperty' - $result.minProperties | Should -Be 1 - $result.maxProperties | Should -Be 2 $result['example'] | Should -Be 'Example for New-PodeOASchemaProperty' $result['readOnly'] | Should -Be $true $result.array | Should -BeTrue From 6e1ff3b2be774128feaaf66690655284f448a08c Mon Sep 17 00:00:00 2001 From: mdaneri Date: Tue, 15 Oct 2024 10:32:29 -0700 Subject: [PATCH 3/4] add localization and fix test --- src/Locales/ar/Pode.psd1 | 1 + src/Locales/de/Pode.psd1 | 1 + src/Locales/en-us/Pode.psd1 | 2 +- src/Locales/en/Pode.psd1 | 1 + src/Locales/es/Pode.psd1 | 1 + src/Locales/fr/Pode.psd1 | 4 +-- src/Locales/it/Pode.psd1 | 1 + src/Locales/ja/Pode.psd1 | 1 + src/Locales/ko/Pode.psd1 | 1 + src/Locales/nl/Pode.psd1 | 1 + src/Locales/pl/Pode.psd1 | 1 + src/Locales/pt/Pode.psd1 | 1 + src/Locales/zh/Pode.psd1 | 1 + src/Public/OpenApi.ps1 | 21 +++++++++++-- tests/unit/OpenApi.Tests.ps1 | 57 ++++++++++++++++++++++++++++++++++++ 15 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/Locales/ar/Pode.psd1 b/src/Locales/ar/Pode.psd1 index 978646dab..7f08cd0f0 100644 --- a/src/Locales/ar/Pode.psd1 +++ b/src/Locales/ar/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = 'لا يمكن أن تحتوي عمليات {0} على محتوى الطلب.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "الدالة '{0}' لا تقبل مصفوفة كمدخل لأنبوب البيانات." unsupportedStreamCompressionEncodingExceptionMessage = 'تشفير الضغط غير مدعوم للتشفير {0}' + LocalEndpointConflictExceptionMessage = "تم تعريف كل من '{0}' و '{1}' كنقاط نهاية محلية لـ OpenAPI، لكن يُسمح فقط بنقطة نهاية محلية واحدة لكل تعريف API." } diff --git a/src/Locales/de/Pode.psd1 b/src/Locales/de/Pode.psd1 index 4d70c92aa..aa72d5f1b 100644 --- a/src/Locales/de/Pode.psd1 +++ b/src/Locales/de/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = '{0}-Operationen können keinen Anforderungstext haben.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "Die Funktion '{0}' akzeptiert kein Array als Pipeline-Eingabe." unsupportedStreamCompressionEncodingExceptionMessage = 'Die Stream-Komprimierungskodierung wird nicht unterstützt: {0}' + LocalEndpointConflictExceptionMessage = "Sowohl '{0}' als auch '{1}' sind als lokale OpenAPI-Endpunkte definiert, aber es ist nur ein lokaler Endpunkt pro API-Definition erlaubt." } \ No newline at end of file diff --git a/src/Locales/en-us/Pode.psd1 b/src/Locales/en-us/Pode.psd1 index 85ef1c3a5..8b62cceca 100644 --- a/src/Locales/en-us/Pode.psd1 +++ b/src/Locales/en-us/Pode.psd1 @@ -291,4 +291,4 @@ getRequestBodyNotAllowedExceptionMessage = '{0} operations cannot have a Request Body.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "The function '{0}' does not accept an array as pipeline input." unsupportedStreamCompressionEncodingExceptionMessage = 'Unsupported stream compression encoding: {0}' -} \ No newline at end of file + LocalEndpointConflictExceptionMessage = "Both '{0}' and '{1}' are defined as local OpenAPI endpoints, but only one local endpoint is allowed per API definition."} \ No newline at end of file diff --git a/src/Locales/en/Pode.psd1 b/src/Locales/en/Pode.psd1 index 4aa2f34f7..b5c8166b7 100644 --- a/src/Locales/en/Pode.psd1 +++ b/src/Locales/en/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = '{0} operations cannot have a Request Body.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "The function '{0}' does not accept an array as pipeline input." unsupportedStreamCompressionEncodingExceptionMessage = 'Unsupported stream compression encoding: {0}' + LocalEndpointConflictExceptionMessage = "Both '{0}' and '{1}' are defined as local OpenAPI endpoints, but only one local endpoint is allowed per API definition." } \ No newline at end of file diff --git a/src/Locales/es/Pode.psd1 b/src/Locales/es/Pode.psd1 index 409357fe4..17986c8df 100644 --- a/src/Locales/es/Pode.psd1 +++ b/src/Locales/es/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = 'Las operaciones {0} no pueden tener un cuerpo de solicitud.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "La función '{0}' no acepta una matriz como entrada de canalización." unsupportedStreamCompressionEncodingExceptionMessage = 'La codificación de compresión de transmisión no es compatible: {0}' + LocalEndpointConflictExceptionMessage = "Tanto '{0}' como '{1}' están definidos como puntos finales locales de OpenAPI, pero solo se permite un punto final local por definición de API." } \ No newline at end of file diff --git a/src/Locales/fr/Pode.psd1 b/src/Locales/fr/Pode.psd1 index c543ae136..30ef4207f 100644 --- a/src/Locales/fr/Pode.psd1 +++ b/src/Locales/fr/Pode.psd1 @@ -291,5 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = 'Les opérations {0} ne peuvent pas avoir de corps de requête.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "La fonction '{0}' n'accepte pas un tableau en tant qu'entrée de pipeline." unsupportedStreamCompressionEncodingExceptionMessage = "La compression de flux {0} n'est pas prise en charge." -} - + LocalEndpointConflictExceptionMessage = "Les deux '{0}' et '{1}' sont définis comme des points de terminaison locaux pour OpenAPI, mais un seul point de terminaison local est autorisé par définition d'API." +} \ No newline at end of file diff --git a/src/Locales/it/Pode.psd1 b/src/Locales/it/Pode.psd1 index cbc7ebb2c..db611c884 100644 --- a/src/Locales/it/Pode.psd1 +++ b/src/Locales/it/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = 'Le operazioni {0} non possono avere un corpo della richiesta.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "La funzione '{0}' non accetta una matrice come input della pipeline." unsupportedStreamCompressionEncodingExceptionMessage = 'La compressione dello stream non è supportata per la codifica {0}' + LocalEndpointConflictExceptionMessage = "Sia '{0}' che '{1}' sono definiti come endpoint locali OpenAPI, ma è consentito solo un endpoint locale per definizione API." } \ No newline at end of file diff --git a/src/Locales/ja/Pode.psd1 b/src/Locales/ja/Pode.psd1 index 5af361d24..9ffd2171b 100644 --- a/src/Locales/ja/Pode.psd1 +++ b/src/Locales/ja/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = '{0}操作にはリクエストボディを含めることはできません。' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "関数 '{0}' は配列をパイプライン入力として受け付けません。" unsupportedStreamCompressionEncodingExceptionMessage = 'サポートされていないストリーム圧縮エンコーディングが提供されました: {0}' + LocalEndpointConflictExceptionMessage = "'{0}' と '{1}' は OpenAPI のローカルエンドポイントとして定義されていますが、API 定義ごとに 1 つのローカルエンドポイントのみ許可されます。" } \ No newline at end of file diff --git a/src/Locales/ko/Pode.psd1 b/src/Locales/ko/Pode.psd1 index 26dc8a116..b98bcb436 100644 --- a/src/Locales/ko/Pode.psd1 +++ b/src/Locales/ko/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = '{0} 작업에는 요청 본문이 있을 수 없습니다.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "함수 '{0}'은(는) 배열을 파이프라인 입력으로 받지 않습니다." unsupportedStreamCompressionEncodingExceptionMessage = '지원되지 않는 스트림 압축 인코딩: {0}' + LocalEndpointConflictExceptionMessage = "'{0}' 와 '{1}' 는 OpenAPI 로컬 엔드포인트로 정의되었지만, API 정의당 하나의 로컬 엔드포인트만 허용됩니다." } \ No newline at end of file diff --git a/src/Locales/nl/Pode.psd1 b/src/Locales/nl/Pode.psd1 index 8e88fe7d5..be6dfe335 100644 --- a/src/Locales/nl/Pode.psd1 +++ b/src/Locales/nl/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = '{0}-operaties kunnen geen Request Body hebben.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "De functie '{0}' accepteert geen array als pipeline-invoer." unsupportedStreamCompressionEncodingExceptionMessage = 'Niet-ondersteunde streamcompressie-encodering: {0}' + LocalEndpointConflictExceptionMessage = "Zowel '{0}' als '{1}' zijn gedefinieerd als lokale OpenAPI-eindpunten, maar er is slechts één lokaal eindpunt per API-definitie toegestaan." } \ No newline at end of file diff --git a/src/Locales/pl/Pode.psd1 b/src/Locales/pl/Pode.psd1 index afbcb3dc2..1cd919eb3 100644 --- a/src/Locales/pl/Pode.psd1 +++ b/src/Locales/pl/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = 'Operacje {0} nie mogą mieć treści żądania.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "Funkcja '{0}' nie akceptuje tablicy jako wejścia potoku." unsupportedStreamCompressionEncodingExceptionMessage = 'Kodowanie kompresji strumienia nie jest obsługiwane: {0}' + LocalEndpointConflictExceptionMessage = "Zarówno '{0}', jak i '{1}' są zdefiniowane jako lokalne punkty końcowe OpenAPI, ale na jedną definicję API dozwolony jest tylko jeden lokalny punkt końcowy." } \ No newline at end of file diff --git a/src/Locales/pt/Pode.psd1 b/src/Locales/pt/Pode.psd1 index af6d8731b..079822c50 100644 --- a/src/Locales/pt/Pode.psd1 +++ b/src/Locales/pt/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = 'As operações {0} não podem ter um corpo de solicitação.' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "A função '{0}' não aceita uma matriz como entrada de pipeline." unsupportedStreamCompressionEncodingExceptionMessage = 'A codificação de compressão de fluxo não é suportada.' + LocalEndpointConflictExceptionMessage = "Tanto '{0}' quanto '{1}' estão definidos como endpoints locais do OpenAPI, mas apenas um endpoint local é permitido por definição de API." } \ No newline at end of file diff --git a/src/Locales/zh/Pode.psd1 b/src/Locales/zh/Pode.psd1 index 9e7652920..34ff282a9 100644 --- a/src/Locales/zh/Pode.psd1 +++ b/src/Locales/zh/Pode.psd1 @@ -291,4 +291,5 @@ getRequestBodyNotAllowedExceptionMessage = '{0} 操作不能包含请求体。' fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "函数 '{0}' 不接受数组作为管道输入。" unsupportedStreamCompressionEncodingExceptionMessage = '不支持的流压缩编码: {0}' + LocalEndpointConflictExceptionMessage = "'{0}' 和 '{1}' 都被定义为 OpenAPI 的本地端点,但每个 API 定义仅允许一个本地端点。" } \ No newline at end of file diff --git a/src/Public/OpenApi.ps1 b/src/Public/OpenApi.ps1 index 82dccc859..bd94fcf37 100644 --- a/src/Public/OpenApi.ps1 +++ b/src/Public/OpenApi.ps1 @@ -395,28 +395,45 @@ function Add-PodeOAServerEndpoint { $DefinitionTag ) + + # If the DefinitionTag is empty, use the selected tag from Pode's OpenAPI context if (Test-PodeIsEmpty -Value $DefinitionTag) { $DefinitionTag = @($PodeContext.Server.OpenAPI.SelectedDefinitionTag) } + + # Loop through each tag to add the server object to the corresponding OpenAPI definition foreach ($tag in $DefinitionTag) { + # If the 'servers' array for the tag doesn't exist, initialize it as an empty array if (! $PodeContext.Server.OpenAPI.Definitions[$tag].servers) { $PodeContext.Server.OpenAPI.Definitions[$tag].servers = @() } + + # Create an ordered hashtable representing the server object with the URL $lUrl = [ordered]@{url = $Url } + + # If a description is provided, add it to the server object if ($Description) { $lUrl.description = $Description } + # If variables are provided, add them to the server object if ($Variables) { $lUrl.variables = $Variables } - if ($lUrl -notmatch '^(?i)https?://') { + + # Check if the URL is a local endpoint (not starting with 'http(s)://') + if ($lUrl.url -notmatch '^(?i)https?://') { + # Loop through existing server URLs in the definition foreach ($srv in $PodeContext.Server.OpenAPI.Definitions[$tag].servers) { + # If there's already a local endpoint, throw an exception, as only one local endpoint is allowed per definition + # Both are defined as local OpenAPI endpoints, but only one local endpoint is allowed per API definition. if ($srv.url -notmatch '^(?i)https?://') { - throw ("Both '{0}' and '{1}' are defined as local OpenAPI endpoints, but only one local endpoint is allowed per API definition." -f $Url, $srv.url) + throw ($PodeLocale.LocalEndpointConflictExceptionMessage -f $Url, $srv.url) } } } + + # Add the new server object to the OpenAPI definition for the current tag $PodeContext.Server.OpenAPI.Definitions[$tag].servers += $lUrl } } diff --git a/tests/unit/OpenApi.Tests.ps1 b/tests/unit/OpenApi.Tests.ps1 index 4f16f79e4..d42a13698 100644 --- a/tests/unit/OpenApi.Tests.ps1 +++ b/tests/unit/OpenApi.Tests.ps1 @@ -3218,6 +3218,63 @@ Describe 'OpenApi' { } } + Describe 'Add-PodeOAServerEndpoint' { + # Mocking Pode related context and functions + BeforeAll { + + + function Test-PodeIsEmpty { + param ($Value) + return -not $Value + } + } + + Context 'When adding a server with URL and description' { + It 'Should add the server to the OpenAPI definition' { + Add-PodeOAServerEndpoint -Url 'https://myserver.io/api' -Description 'My test server' + + $servers = $PodeContext.Server.OpenAPI.Definitions['default'].servers + $servers | Should -HaveCount 1 + $servers[0].url | Should -Be 'https://myserver.io/api' + $servers[0].description | Should -Be 'My test server' + } + } + + Context 'When adding a server with variables' { + It 'Should add the server with variables to the OpenAPI definition' { + $variables = [ordered]@{ + username = [ordered]@{ + default = 'demo' + description = 'assigned by provider' + } + port = [ordered]@{ + default = 8443 + } + basePath = [ordered]@{ + default = 'v2' + } + } + + Add-PodeOAServerEndpoint -Url 'https://{username}.server.com:{port}/{basePath}' -Variables $variables + + $servers = $PodeContext.Server.OpenAPI.Definitions['default'].servers + $servers | Should -HaveCount 1 + $servers[0].url | Should -Be 'https://{username}.server.com:{port}/{basePath}' + $servers[0].variables | Should -Be $variables + } + } + + Context 'When adding multiple local endpoints' { + It 'Should throw an error when multiple local URLs are defined' { + Add-PodeOAServerEndpoint -Url '/api' -Description 'Local endpoint 1' + + { Add-PodeOAServerEndpoint -Url '/api/v2' -Description 'Local endpoint 2' } | + Should -Throw "Both '/api/v2' and '/api' are defined as local OpenAPI endpoints, but only one local endpoint is allowed per API definition." + } + } + + + } Context 'Pet Object example' { From da691d2bcfcc7a85a8907f672d4e1ee523aa32fd Mon Sep 17 00:00:00 2001 From: mdaneri <17148649+mdaneri@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:38:58 -0700 Subject: [PATCH 4/4] Update OpenApi-TuttiFrutti.ps1 --- examples/OpenApi-TuttiFrutti.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/OpenApi-TuttiFrutti.ps1 b/examples/OpenApi-TuttiFrutti.ps1 index 7527543e5..d024686c1 100644 --- a/examples/OpenApi-TuttiFrutti.ps1 +++ b/examples/OpenApi-TuttiFrutti.ps1 @@ -101,7 +101,7 @@ Some useful links: Enable-PodeOAViewer -Type Swagger -Path '/docs/swagger' -DefinitionTag 'v3' Enable-PodeOAViewer -Type ReDoc -Path '/docs/redoc' -DarkMode -DefinitionTag 'v3' - Enable-PodeOAViewer -Type RapiDoc -Path '5/docs/rapidoc' -DarkMode -DefinitionTag 'v3' + Enable-PodeOAViewer -Type RapiDoc -Path '/docs/rapidoc' -DarkMode -DefinitionTag 'v3' Enable-PodeOAViewer -Type StopLight -Path '/docs/stoplight' -DarkMode -DefinitionTag 'v3' Enable-PodeOAViewer -Type Explorer -Path '/docs/explorer' -DarkMode -DefinitionTag 'v3' Enable-PodeOAViewer -Type RapiPdf -Path '/docs/rapipdf' -DarkMode -DefinitionTag 'v3'