From be25cb695bf554db9056c0620668e3ae40a1557f Mon Sep 17 00:00:00 2001 From: frantuma Date: Mon, 28 Nov 2022 21:03:29 +0100 Subject: [PATCH] test: enhance OAS 3.1 tests --- NOTICE | 13 +- README.md | 7 + .../v3/parser/test/OpenAPIResolverTest.java | 187 ++- .../test/OpenAPIV31ParserFSFullTest.java | 22 + .../dereference/fullFS/dereferenced.yaml | 91 ++ .../fullFS/dereferencedflatten.yaml | 91 ++ .../dereference/fullFS/dereferencedfully.yaml | 118 ++ .../3.1.0/dereference/fullFS/ex.json | 8 + .../3.1.0/dereference/fullFS/ex1.json | 3 + .../3.1.0/dereference/fullFS/ex1a.json | 5 + .../3.1.0/dereference/fullFS/ex1schema.json | 11 + .../3.1.0/dereference/fullFS/ex2.json | 7 + .../3.1.0/dereference/fullFS/ex2schema.json | 11 + .../3.1.0/dereference/fullFS/ex3schema.json | 9 + .../dereference/fullFS/nested/domain.yaml | 28 + .../3.1.0/dereference/fullFS/nested/ex2a.json | 5 + .../3.1.0/dereference/fullFS/nested/ex3a.json | 8 + .../3.1.0/dereference/fullFS/root.json | 103 ++ .../src/test/resources/oas31.yaml.template | 1351 +++++++++++++++++ pom.xml | 2 +- 20 files changed, 2069 insertions(+), 11 deletions(-) create mode 100644 modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV31ParserFSFullTest.java create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferenced.yaml create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedflatten.yaml create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedfully.yaml create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1a.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1schema.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2schema.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex3schema.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/domain.yaml create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex2a.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex3a.json create mode 100644 modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/root.json create mode 100644 modules/swagger-parser-v3/src/test/resources/oas31.yaml.template diff --git a/NOTICE b/NOTICE index e186bb8bf7..20548f34aa 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,15 @@ Swagger Parser - ${pom.name} Copyright (c) 2015. SmartBear Software Inc. Swagger Parser - ${pom.name} is licensed under Apache 2.0 license. -Copy of the Apache 2.0 license can be found in `LICENSE` file. \ No newline at end of file +Copy of the Apache 2.0 license can be found in `LICENSE` file. + +ApiDOM +Copyright 2020 SmartBear Software Inc. +ApiDOM is licensed under Apache 2.0 license. +Directory modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fixtures was originally created under Apache 2.0 license in https://github.com/swagger-api/apidom repository. +Directory modules/swagger-parser-v3/src/test/resources/3.1.0/resolve/fixtures was originally created under Apache 2.0 license in https://github.com/swagger-api/apidom repository. +These directories have been copied into this project and modified. All modifications are licensed under Apache 2.0 License. +Copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt` file. + + + diff --git a/README.md b/README.md index fbc48f9cbe..82e86d1a56 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ **NOTE:** If you're looking for `swagger-parser` 1.X and OpenAPI 2.0, please refer to [v1 branch](https://github.com/swagger-api/swagger-parser/tree/v1) +**NOTE:** Since version 2.1.0 Swagger Parser supports OpenAPI 3.1; see [this page](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---OpenAPI-3.1) for details + ![Build Master - Java 8, 11, and 14](https://github.com/swagger-api/swagger-parser/workflows/Build%20Test%20Deploy%20master/badge.svg?branch=master) # Table of contents @@ -18,6 +20,7 @@ - [Flatten](#3-flatten) - [ResolveCombinators](#4-resolvecombinators) - [Extensions](#extensions) + - [OpenAPI 3.1 Support](#openapi-31-support) - [License](#license) ## Overview @@ -657,6 +660,10 @@ This project has a core artifact--`swagger-parser`, which uses Java Service Prov To build your own extension, you simply need to create a `src/main/resources/META-INF/services/io.swagger.v3.parser.core.extensions.SwaggerParserExtension` file with the full classname of your implementation. Your class must also implement the `io.swagger.v3.parser.core.extensions.SwaggerParserExtension` interface. Then, including your library with the `swagger-parser` module will cause it to be triggered automatically. +### OpenAPI 3.1 support + +Since version 2.1.0 Swagger Parser supports OpenAPI 3.1; see [this page](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---OpenAPI-3.1) for details + ## Security contact Please disclose any security-related issues or vulnerabilities by emailing [security@swagger.io](mailto:security@swagger.io), instead of using the public issue tracker. diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java index 1534488899..fd4c236a92 100644 --- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java +++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java @@ -40,6 +40,9 @@ import io.swagger.v3.parser.core.models.SwaggerParseResult; import io.swagger.v3.parser.processors.ComponentsProcessor; import io.swagger.v3.parser.processors.PathsProcessor; +import io.swagger.v3.parser.reference.DereferencerContext; +import io.swagger.v3.parser.reference.DereferencersFactory; +import io.swagger.v3.parser.reference.OpenAPIDereferencer; import io.swagger.v3.parser.util.OpenAPIDeserializer; import io.swagger.v3.parser.util.ResolverFully; import mockit.Injectable; @@ -207,6 +210,172 @@ private void tearDownWireMockServer() { this.wireMockServer.stop(); } + @Test + public void componentsResolver31() throws Exception { + final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + + String pathFile = FileUtils.readFileToString(new File("src/test/resources/oas31.yaml.template")); + pathFile = pathFile.replace("${dynamicPort}", String.valueOf(this.serverPort)); + + final JsonNode rootNode = mapper.readTree(pathFile.getBytes()); + final OpenAPIDeserializer deserializer = new OpenAPIDeserializer(); + final SwaggerParseResult result = deserializer.deserialize(rootNode); + + Assert.assertNotNull(result); + final OpenAPI openAPI = result.getOpenAPI(); + Assert.assertNotNull(openAPI); + DereferencerContext dereferencerContext = new DereferencerContext( + result, + new ArrayList<>(), + null, + new ParseOptions(), + null, + null, + true + ); + List dereferencers = DereferencersFactory.getInstance().getDereferencers(); + if (dereferencers.iterator().hasNext()) { + OpenAPIDereferencer dereferencer = dereferencers.iterator().next(); + dereferencer.dereference(dereferencerContext, dereferencers.iterator()); + } + assertEquals(dereferencerContext.getOpenApi(), openAPI); + + Map schemas = openAPI.getComponents().getSchemas(); + + //internal url schema + Schema pet = schemas.get("Pet"); + Schema category = (Schema) pet.getProperties().get("category"); + assertEquals(category.get$ref(),"#/components/schemas/Category"); + + //remote url schema + Schema user = (Schema) pet.getProperties().get("user"); + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(user.get$ref(),"#/components/schemas/User"); + + + //ArraySchema items + Schema tagsProperty = (Schema) pet.getProperties().get("tags"); + // TODO uncomment when bundling of extenrnal refs gets implemented +/* assertEquals(tagsProperty.getItems().get$ref(), "#/components/schemas/ExampleSchema" ); + assertEquals(tagsProperty.getType(),"array"); + Assert.assertNotNull(openAPI.getComponents().getSchemas().get("ExampleSchema"));*/ + + //Schema not + assertEquals(schemas.get("OrderRef").getNot().get$ref(), "#/components/schemas/Category"); + + //Schema additionalProperties + assertTrue(schemas.get("OrderRef").getAdditionalProperties() instanceof Schema); + Schema additionalProperties = (Schema) schemas.get("OrderRef").getAdditionalProperties(); + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(additionalProperties.get$ref(), "#/components/schemas/User"); + + //AllOfSchema + Schema extended = schemas.get("ExtendedErrorModel"); + Schema root = (Schema) ((Schema)extended.getAllOf().get(0)).getProperties().get("rootCause"); + assertEquals(root.get$ref(), "#/components/schemas/Category"); + + + Map responses = openAPI.getComponents().getResponses(); + + //internal response headers + ApiResponse illegalInput = responses.get("IllegalInput"); + assertEquals(illegalInput.getHeaders().get("X-Ref-Limit-Limit").get$ref(),"#/components/headers/X-Rate-Limit-Reset"); + + //internal response links + assertEquals(illegalInput.getLinks().get("address").get$ref(),"#/components/links/unsubscribe"); + + //internal url response schema + MediaType generalError = responses.get("GeneralError").getContent().get("application/json"); + assertEquals(generalError.getSchema().get$ref(),"#/components/schemas/ExtendedErrorModel"); + + + Map requestBodies = openAPI.getComponents().getRequestBodies(); + + //internal url requestBody schema + RequestBody requestBody1 = requestBodies.get("requestBody1"); + MediaType xmlMedia = requestBody1.getContent().get("application/json"); + assertEquals(xmlMedia.getSchema().get$ref(),"#/components/schemas/Pet"); + + //internal url requestBody ArraySchema + RequestBody requestBody2 = requestBodies.get("requestBody2"); + MediaType jsonMedia = requestBody2.getContent().get("application/json"); + Schema items = jsonMedia.getSchema(); + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(items.getItems().get$ref(),"#/components/schemas/User"); + + //internal request body + assertEquals("#/components/requestBodies/requestBody2",requestBodies.get("requestBody3").get$ref()); + + //remote request body url + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(requestBodies.get("reference").get$ref(),"#/components/requestBodies/remote_requestBody"); + + Map parameters = openAPI.getComponents().getParameters(); + + //remote url parameter + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(parameters.get("remoteParameter").get$ref(),"#/components/parameters/parameter"); + + + //internal Schema Parameter + assertEquals(parameters.get("newParam").getSchema().get$ref(),"#/components/schemas/Tag"); + + + //parameter content schema + + assertEquals(parameters.get("contentParameter").getContent().get("application/json").getSchema().get$ref(),"#/components/schemas/ExtendedErrorModel"); + + //internal Schema header + Map headers = openAPI.getComponents().getHeaders(); + //header remote schema ref + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(headers.get("X-Rate-Limit-Remaining").getSchema().get$ref(),"#/components/schemas/User"); + + //header examples + assertEquals(headers.get("X-Rate-Limit-Reset").getExamples().get("headerExample").get$ref(), "#/components/examples/dog" ); + //remote header ref + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(headers.get("X-Ref-Limit-Limit").get$ref(),"#/components/headers/X-Rate-Limit-Reset" ); + + + //header content + assertEquals(headers.get("X-Rate-Limit-Reset").getContent().get("application/json").getSchema().get$ref(),"#/components/schemas/ExtendedErrorModel"); + + Map examples = openAPI.getComponents().getExamples(); + + //internal url example + Example frogExample = examples.get("frog"); + assertEquals(frogExample.get$ref(),"#/components/examples/cat"); + + //remote example url + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(examples.get("referenceCat").get$ref(),"#/components/examples/example"); + + + SecurityScheme remoteScheme = openAPI.getComponents().getSecuritySchemes().get("remote_reference"); + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(remoteScheme.getType(), SecurityScheme.Type.OAUTH2); + + + Map links = openAPI.getComponents().getLinks(); + //internal link + assertEquals(openAPI.getComponents().getLinks().get("referenced").get$ref(),"#/components/links/unsubscribe"); + //remote ref link + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(openAPI.getComponents().getLinks().get("subscribe").get$ref(),"#/components/links/link"); + + + Map callbacks = openAPI.getComponents().getCallbacks(); + // internal callback reference + assertEquals(callbacks.get("referenced").get$ref(),"#/components/callbacks/failed"); + //callback pathItem -> operation ->requestBody + assertEquals(callbacks.get("heartbeat").get("$request.query.heartbeat-url").getPost().getRequestBody().get$ref(),"#/components/requestBodies/requestBody3"); + //remote callback ref + // TODO uncomment when bundling of extenrnal refs gets implemented + // assertEquals(callbacks.get("remoteCallback").get$ref(),"#/components/callbacks/callback"); + + } + @Test public void componentsResolver() throws Exception { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); @@ -236,7 +405,7 @@ public void componentsResolver() throws Exception { //ArraySchema items - ArraySchema tagsProperty = (ArraySchema) pet.getProperties().get("tags"); + Schema tagsProperty = (ArraySchema) pet.getProperties().get("tags"); assertEquals(tagsProperty.getItems().get$ref(), "#/components/schemas/ExampleSchema" ); assertEquals(tagsProperty.getType(),"array"); Assert.assertNotNull(openAPI.getComponents().getSchemas().get("ExampleSchema")); @@ -250,8 +419,8 @@ public void componentsResolver() throws Exception { assertEquals(additionalProperties.get$ref(), "#/components/schemas/User"); //AllOfSchema - ComposedSchema extended = (ComposedSchema) schemas.get("ExtendedErrorModel"); - Schema root = (Schema) extended.getAllOf().get(0).getProperties().get("rootCause"); + Schema extended = (ComposedSchema) schemas.get("ExtendedErrorModel"); + Schema root = (Schema)((Schema) extended.getAllOf().get(0)).getProperties().get("rootCause"); assertEquals(root.get$ref(), "#/components/schemas/Category"); @@ -595,7 +764,7 @@ public void testIssue1170(@Injectable final List auths) { assertTrue(colouringPropertySchema == colouringsSchema); } - + @Test public void testIssue1706() { String path = "/issue-1706/SimpleRequestResponseRef.json"; @@ -606,19 +775,19 @@ public void testIssue1706() { options.setResolveRequestBody(true); OpenAPI openAPI = new OpenAPIV3Parser().readLocation(path, null, options).getOpenAPI(); - + // RequestBody should be inline assertTrue(openAPI.getPaths().get("/resource").getPost().getRequestBody().get$ref() == null); assertTrue(openAPI.getPaths().get("/resource").getPost().getRequestBody().getContent() != null); assertTrue(openAPI.getPaths().get("/resource").getPost().getRequestBody().getContent().get("application/json").getSchema() instanceof ObjectSchema); - + // Responses are already by default made inline in case referenced. assertTrue(openAPI.getPaths().get("/resource").getPost().getResponses().get("200").get$ref() == null); assertTrue(openAPI.getPaths().get("/resource").getPost().getResponses().get("200").getContent() != null); - assertTrue(openAPI.getPaths().get("/resource").getPost().getResponses().get("200").getContent().get("application/json").getSchema() instanceof ObjectSchema); + assertTrue(openAPI.getPaths().get("/resource").getPost().getResponses().get("200").getContent().get("application/json").getSchema() instanceof ObjectSchema); } - - + + @Test public void selfReferenceTest(@Injectable final List auths) { diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV31ParserFSFullTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV31ParserFSFullTest.java new file mode 100644 index 0000000000..88d302f0dd --- /dev/null +++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV31ParserFSFullTest.java @@ -0,0 +1,22 @@ +package io.swagger.v3.parser.test; + +import io.swagger.v3.core.util.Yaml31; +import io.swagger.v3.parser.OpenAPIV3Parser; +import io.swagger.v3.parser.core.models.ParseOptions; +import io.swagger.v3.parser.core.models.SwaggerParseResult; +import org.apache.commons.io.FileUtils; +import org.testng.annotations.Test; + +import java.io.File; + +public class OpenAPIV31ParserFSFullTest { + + @Test + public void testFull() throws Exception { + ParseOptions p = new ParseOptions(); + p.setResolve(true); + String uri = "3.1.0/dereference/fullFS/root.json"; + SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser().readLocation(uri, null, p); + org.testng.Assert.assertEquals(Yaml31.pretty(swaggerParseResult.getOpenAPI()), FileUtils.readFileToString(new File("src/test/resources/3.1.0/dereference/fullFS/dereferenced.yaml"))); + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferenced.yaml b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferenced.yaml new file mode 100644 index 0000000000..79788fe55f --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferenced.yaml @@ -0,0 +1,91 @@ +openapi: 3.1.0 +servers: +- url: / +paths: + /path1: + summary: path item summary + description: /path3 ex2 + get: {} + /relativeref: + get: + description: RelativeRef domain + operationId: RelativeRef PathItem + responses: + "200": + description: OK + /internalref: + $ref: '#/components/pathItems/InternalRef' + /internalreftoexternal: + $ref: '#/components/pathItems/InternalRefToExternal' + /internal: + get: + description: Internal PathItem + operationId: Internal PathItem + responses: + "200": + description: OK +components: + schemas: + Indirection: + type: object + description: VALUE ex3schema + properties: + prop1: + type: string + IndirectionSiblings: + type: object + description: IndirectionSiblings root + properties: + prop1: + type: string + parameters: + userId: + description: userId root + $ref: '#/components/parameters/indirection1' + indirection1: + $ref: '#/components/parameters/userIdRef' + indirection2: + description: indirection2 root + $ref: '#/components/parameters/userIdRef' + userIdRef: + name: userId + in: query + description: userIdRef root + required: true + style: form + explode: true + externalRef: + name: externalParameter + in: query + description: externalRef root + required: true + style: form + explode: true + externalRefIndirectPointer: + description: externalRefIndirectPointer root + $ref: '#/components/parameters/externalRefIndirect3' + externalRefIndirect3: + name: externalParameter3 + in: query + description: externalRefIndirect3 root + required: true + style: form + explode: true + links: + link1: + operationRef: ./ex.json#/operation + pathItems: + InternalRefToExternal: + get: + description: DomainInternalRefToExternal domain + operationId: DomainInternalRefToExternal PathItem + responses: + "200": + description: OK + InternalRef: + get: + description: InternalRef root + operationId: InternalRef PathItem + responses: + "200": + description: OK diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedflatten.yaml b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedflatten.yaml new file mode 100644 index 0000000000..79788fe55f --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedflatten.yaml @@ -0,0 +1,91 @@ +openapi: 3.1.0 +servers: +- url: / +paths: + /path1: + summary: path item summary + description: /path3 ex2 + get: {} + /relativeref: + get: + description: RelativeRef domain + operationId: RelativeRef PathItem + responses: + "200": + description: OK + /internalref: + $ref: '#/components/pathItems/InternalRef' + /internalreftoexternal: + $ref: '#/components/pathItems/InternalRefToExternal' + /internal: + get: + description: Internal PathItem + operationId: Internal PathItem + responses: + "200": + description: OK +components: + schemas: + Indirection: + type: object + description: VALUE ex3schema + properties: + prop1: + type: string + IndirectionSiblings: + type: object + description: IndirectionSiblings root + properties: + prop1: + type: string + parameters: + userId: + description: userId root + $ref: '#/components/parameters/indirection1' + indirection1: + $ref: '#/components/parameters/userIdRef' + indirection2: + description: indirection2 root + $ref: '#/components/parameters/userIdRef' + userIdRef: + name: userId + in: query + description: userIdRef root + required: true + style: form + explode: true + externalRef: + name: externalParameter + in: query + description: externalRef root + required: true + style: form + explode: true + externalRefIndirectPointer: + description: externalRefIndirectPointer root + $ref: '#/components/parameters/externalRefIndirect3' + externalRefIndirect3: + name: externalParameter3 + in: query + description: externalRefIndirect3 root + required: true + style: form + explode: true + links: + link1: + operationRef: ./ex.json#/operation + pathItems: + InternalRefToExternal: + get: + description: DomainInternalRefToExternal domain + operationId: DomainInternalRefToExternal PathItem + responses: + "200": + description: OK + InternalRef: + get: + description: InternalRef root + operationId: InternalRef PathItem + responses: + "200": + description: OK diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedfully.yaml b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedfully.yaml new file mode 100644 index 0000000000..27d378addf --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/dereferencedfully.yaml @@ -0,0 +1,118 @@ +openapi: 3.1.0 +servers: +- url: / +paths: + /path1: + summary: path item summary + description: /path3 ex2 + get: {} + /relativeref: + get: + description: RelativeRef domain + operationId: RelativeRef PathItem + responses: + "200": + description: OK + /internalref: + get: + description: InternalRef root + operationId: InternalRef PathItem + responses: + "200": + description: OK + /internalreftoexternal: + get: + description: DomainInternalRefToExternal domain + operationId: DomainInternalRefToExternal PathItem + responses: + "200": + description: OK + /internal: + get: + description: Internal PathItem + operationId: Internal PathItem + responses: + "200": + description: OK +components: + schemas: + Indirection: + type: object + description: VALUE ex3schema + properties: + prop1: + type: string + IndirectionSiblings: + type: object + description: IndirectionSiblings root + properties: + prop1: + type: string + parameters: + userId: + name: userId + in: query + description: userId root + required: true + style: form + explode: true + indirection1: + name: userId + in: query + description: userIdRef root + required: true + style: form + explode: true + indirection2: + name: userId + in: query + description: indirection2 root + required: true + style: form + explode: true + userIdRef: + name: userId + in: query + description: userIdRef root + required: true + style: form + explode: true + externalRef: + name: externalParameter + in: query + description: externalRef root + required: true + style: form + explode: true + externalRefIndirectPointer: + name: externalParameter3 + in: query + description: externalRefIndirectPointer root + required: true + style: form + explode: true + externalRefIndirect3: + name: externalParameter3 + in: query + description: externalRefIndirect3 root + required: true + style: form + explode: true + links: + link1: + operationRef: ./ex.json#/operation + pathItems: + InternalRefToExternal: + get: + description: DomainInternalRefToExternal domain + operationId: DomainInternalRefToExternal PathItem + responses: + "200": + description: OK + InternalRef: + get: + description: InternalRef root + operationId: InternalRef PathItem + responses: + "200": + description: OK diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex.json new file mode 100644 index 0000000000..337cb0e6f6 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "externalParameter ex", + "required": true + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1.json new file mode 100644 index 0000000000..d7b3e3be55 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1.json @@ -0,0 +1,3 @@ +{ + "$ref": "./ex2.json#/~1path3" +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1a.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1a.json new file mode 100644 index 0000000000..7171176f3e --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1a.json @@ -0,0 +1,5 @@ +{ + "indirection3": { + "$ref": "./nested/ex2a.json#/indirection3" + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1schema.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1schema.json new file mode 100644 index 0000000000..d1a2bd312c --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex1schema.json @@ -0,0 +1,11 @@ +{ + "$defs": { + "Indirection": { + "$ref": "./ex2schema.json#/$defs/Indirection" + }, + "IndirectionSiblings": { + "$ref": "./ex2schema.json#/$defs/IndirectionSiblings", + "description": "IndirectionSiblings ex1schema" + } + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2.json new file mode 100644 index 0000000000..9abe6c499d --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2.json @@ -0,0 +1,7 @@ +{ + "/path3": { + "summary": "path item summary", + "description": "/path3 ex2", + "get": {} + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2schema.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2schema.json new file mode 100644 index 0000000000..d2ff7ec086 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex2schema.json @@ -0,0 +1,11 @@ +{ + "$defs": { + "Indirection": { + "$ref": "./ex3schema.json" + }, + "IndirectionSiblings": { + "$ref": "./ex3schema.json", + "description": "IndirectionSiblings ex2schema" + } + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex3schema.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex3schema.json new file mode 100644 index 0000000000..e9fc20581b --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/ex3schema.json @@ -0,0 +1,9 @@ +{ + "type": "object", + "description": "VALUE ex3schema", + "properties": { + "prop1": { + "type": "string" + } + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/domain.yaml b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/domain.yaml new file mode 100644 index 0000000000..026c85be0a --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/domain.yaml @@ -0,0 +1,28 @@ +openapi: 3.1.0 +info: + title: Domain + version: '1.0' +components: + pathItems: + ExternalRef: + get: + description: ExternalRef domain + operationId: ExternalRef PathItem + responses: + '200': + description: OK + RelativeRef: + get: + description: RelativeRef domain + operationId: RelativeRef PathItem + responses: + '200': + description: OK + DomainInternalRefToExternal: + get: + description: DomainInternalRefToExternal domain + operationId: DomainInternalRefToExternal PathItem + responses: + '200': + description: OK + diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex2a.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex2a.json new file mode 100644 index 0000000000..fed0158003 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex2a.json @@ -0,0 +1,5 @@ +{ + "indirection3": { + "$ref": "./ex3a.json#/externalParameter3" + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex3a.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex3a.json new file mode 100644 index 0000000000..74a90165ce --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/nested/ex3a.json @@ -0,0 +1,8 @@ +{ + "externalParameter3": { + "name": "externalParameter3", + "in": "query", + "description": "externalParameter3 nested/ex3a", + "required": true + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/root.json b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/root.json new file mode 100644 index 0000000000..64a15002b8 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/3.1.0/dereference/fullFS/root.json @@ -0,0 +1,103 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex1.json" + }, + "/relativeref": { + "$ref": "./nested/domain.yaml#/components/pathItems/RelativeRef" + }, + "/internalref": { + "$ref": "#/components/pathItems/InternalRef" + }, + "/internalreftoexternal": { + "$ref": "#/components/pathItems/InternalRefToExternal" + }, + "/internal": { + "get": { + "description": "Internal PathItem", + "operationId": "Internal PathItem", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "userId root", + "prop1": "value1", + "prop2": "value2" + }, + "indirection1": { + "$ref": "#/components/parameters/userIdRef", + "summary": "indirect summary 1", + "prop1": "value1", + "prop2": "value2" + }, + "indirection2": { + "$ref": "#/components/parameters/userIdRef", + "description": "indirection2 root", + "summary": "indirect summary 2", + "prop1": "value1", + "prop2": "value2" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "userIdRef root", + "required": true + }, + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "externalRef root", + "prop1": "value1", + "prop2": "value2" + }, + "externalRefIndirectPointer": { + "$ref": "#/components/parameters/externalRefIndirect3", + "description": "externalRefIndirectPointer root", + "prop1": "value1", + "prop2": "value2" + }, + "externalRefIndirect3": { + "$ref": "./ex1a.json#/indirection3", + "description": "externalRefIndirect3 root" + } + }, + "pathItems": { + "InternalRefToExternal": { + "$ref": "./nested/domain.yaml#/components/pathItems/DomainInternalRefToExternal" + }, + "InternalRef": { + "get": { + "description": "InternalRef root", + "operationId": "InternalRef PathItem", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "links": { + "link1": { + "operationRef": "./ex.json#/operation" + } + }, + "schemas": { + "Indirection": { + "$ref": "./ex1schema.json#/$defs/Indirection" + }, + "IndirectionSiblings": { + "$ref": "./ex1schema.json#/$defs/IndirectionSiblings", + "description": "IndirectionSiblings root" + } + } + } +} diff --git a/modules/swagger-parser-v3/src/test/resources/oas31.yaml.template b/modules/swagger-parser-v3/src/test/resources/oas31.yaml.template new file mode 100644 index 0000000000..7510240278 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/oas31.yaml.template @@ -0,0 +1,1351 @@ +--- +openapi: 3.1.0 +servers: +- url: http://petstore.swagger.io/v2 +- url: https://development.gigantic-server.com/v1 + description: Development server +- url: https://{username}.gigantic-server.com:{port}/{basePath} + x-server: server extension + description: The production API server + variables: + username: + # note! no enum here means it is an open value + default: demo + description: this value is assigned by the service provider, in this example `gigantic-server.com` + port: + enum: + - 8443 + - 443 + default: 8443 + basePath: + # open meaning there is the opportunity to use special base paths as assigned by the provider, default is `v2` + default: v2 + description: testing overwriting + enum: + - 2222 + - 333 +x-origin: +- url: http://petstore.swagger.io/v2/swagger.json + format: swagger + version: '2.0' + converter: + url: https://github.com/mermade/swagger2openapi + version: 1.2.1 +x-api-title: pet store test api +security: + - api_key: [] + - tokenAuth: [] +info: + description: 'This is a sample server Petstore' + title: Sample Pet Store App + termsOfService: http://swagger.io/terms/ + x-info: info extension + contact: + name: API Support + url: http://www.example.com/support + email: support@example.com + x-contact: contact extension + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + x-license: license extension + version: 1.0.1 +tags: +- name: pet + description: Everything about your Pets + externalDocs: + description: Find out more + url: http://swagger.io +- name: store + description: Access to Petstore orders +- name: user + description: Operations about user + externalDocs: + description: Find out more about our store + url: http://swagger.io +paths: + "/pathItemRef2": + "$ref": '#/paths/~1pet' + "/mockResponses/objectMultipleExamples": + get: + responses: + '200': + description: A string + content: + application/json: + schema: + $ref: '#/components/schemas/User1' + examples: + ArthurDent: + $ref: '#/components/examples/Arthur' + Trillian: + $ref: '#/components/examples/Trillian' + application/yaml: + schema: + $ref: '#/components/schemas/User1' + examples: + ArthurDent: + $ref: '#/components/examples/Arthur' + Trillian: + $ref: '#/components/examples/Trillian' + application/xml: + schema: + $ref: '#/components/schemas/User1' + examples: + ArthurDent: + $ref: '#/components/examples/Arthur' + Trillian: + $ref: '#/components/examples/Trillian' + "/pathItemRef": + "$ref": 'http://localhost:${dynamicPort}/remote/path#/paths/~1pet' + "/pet": + summary: summary + description: description + trace: + description: Dummy operation to test retrieval of trace operations + responses: + 200: + description: Dummy response + post: + externalDocs: + description: Find out more + url: http://swagger.io + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + parameters: [] + responses: + '405': + description: Invalid input + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + title: header schema + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + "$ref": "#/components/requestBodies/requestBody1" + servers: + - url: http://petstore.swagger.io/v2 + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + - "$ref": "#/components/parameters/skipParam" + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + parameters: [] + responses: + '400': + description: A complex object array response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/VeryComplexType' + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + "$ref": "#/components/requestBodies/requestBody1" + "/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 + in: query + description: Status values that need to be considered for filter + required: true + example: "example" + schema: + title: title test + format: int64 + minimum: 1 + maximum: 10 + allOf: + - $ref: '#/components/schemas/Pet' + - type: object + properties: + huntingSkill: + type: string + description: The measured skill for hunting + enum: + - clueless + - lazy + - adventurous + - aggressive + xml: + namespace: http://example.com/schema/sample + prefix: sample + enum: + - available + - pending + - sold + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + namespace: http://inside/properties/schema + prefix: inside properties schema + required: + - name + - pet + example: + name: Puma + id: 1 + externalDocs: + description: External Docs Inside Schema + url: http://swagger.io inside Schema + items: + type: string + enum: + - available + - pending + - sold + default: available + 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 + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + description: pet store to add to the system + required: true + content: + multipart/mixed: + schema: + type: object + properties: + id: + # default is text/plain + type: string + format: uuid + "$ref": "#/components/schemas/Pet" + address: + # default is application/json + type: object + properties: {} + historyMetadata: + # need to declare XML format! + description: metadata in XML format + type: object + properties: {} + profileImage: + # default is application/octet-stream, need to declare an image type only! + type: string + format: binary + encoding: + historyMetadata: + # require XML Content-Type in utf-8 encoding + contentType: application/xml; charset=utf-8 + profileImage: + # only accept png/jpeg + contentType: image/png, image/jpeg + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + callbacks: + mainHook: + '$request.body#/url': + post: + responses: + '200': + description: webhook successfully processed operation + "/pet/findByStatusContent": + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatusContent + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + example: "example" + content: + 'application/json': + schema: + type: array + items: + type: string + example: example string + examples: + list: + summary: List of Names + value: + - Bob + - Diane + - Mary + - Bill + empty: + summary: Empty + value: {} + encoding: + historyMetadata: + # require XML Content-Type in utf-8 encoding + contentType: application/xml; charset=utf-8 + profileImage: + # only accept png/jpeg + contentType: image/png, image/jpeg + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + - name: statusXml + in: query + description: Status values that need to be considered for filter + required: true + example: "example" + content: + 'application/xml': + examples: + list: + summary: List of names + value: "" + empty: + summary: Empty list + value: "" + - name: statusText + in: query + description: Status values that need to be considered for filter + required: true + example: "example" + content: + 'text/plain': + examples: + list: + summary: List of names + value: "Bob,Diane,Mary,Bill" + empty: + summary: Empty + value: "" + 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 + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + description: pet store to add to the system + required: true + content: + multipart/mixed: + schema: + type: object + properties: + id: + # default is text/plain + type: string + format: uuid + "$ref": "#/components/schemas/Pet" + address: + # default is application/json + type: object + properties: {} + historyMetadata: + # need to declare XML format! + description: metadata in XML format + type: object + properties: {} + profileImage: + # default is application/octet-stream, need to declare an image type only! + type: string + format: binary + encoding: + historyMetadata: + # require XML Content-Type in utf-8 encoding + contentType: application/xml; charset=utf-8 + profileImage: + # only accept png/jpeg + contentType: image/png, image/jpeg + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + callbacks: + mainHook: + '$request.body#/url': + post: + responses: + '200': + description: webhook successfully processed operation + "/pet/findByTags": + get: + tags: + - pet + summary: Finds Pets by tags + description: Muliple tags can be provided with comma separated strings. Use + tag1, tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + schema: + type: array + items: + type: string + 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 tag value + callbacks: + mainHook: + '$ref': "#/components/callbacks/failed" + security: + - petstore_auth: + - write:pets + - read:pets + deprecated: true + "/pet/{petId}": + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + "$ref": "#/components/schemas/Pet" + application/json: + schema: + "$ref": "#/components/schemas/Pet" + callbacks: + mainHook: + '$request.body#/url': + post: + responses: + '200': + description: successful operation + content: + application/xml: + schema: + "$ref": "#/components/schemas/Pet" + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + required: false + status: + description: Updated status of the pet + type: string + required: false + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - petstore_auth: + - write:pets + - read:pets + "/pet/{petId}/uploadImage": + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + "$ref": "#/components/schemas/ApiResponse" + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + content: + application/octet-stream: + schema: + type: string + format: binary + "/store/inventory": + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + parameters: + - "$ref": "#/components/parameters/limitParam" + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + "/store/order": + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + parameters: [] + responses: + '200': + description: successful operation + content: + application/xml: + schema: + "$ref": "#/components/schemas/Order" + application/json: + schema: + "$ref": "#/components/schemas/Order" + '400': + description: Invalid Order + requestBody: + content: + application/json: + description: order placed for purchasing the pet + schema: + "$ref": "#/components/schemas/Order" + "/store/order/{orderId}": + get: + tags: + - store + summary: Find purchase order by ID + description: For valid response try integer IDs with value >= 1 and <= 10. Other + values will generated exceptions + operationId: getOrderById + parameters: + - name: orderId + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 10 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + "$ref": "#/components/schemas/Order" + application/json: + schema: + "$ref": "#/components/schemas/Order" + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: For valid response try integer IDs with positive integer value. + Negative or non-integer values will generate API errors + operationId: deleteOrder + parameters: + - name: orderId + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: integer + format: int64 + minimum: 1 + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + "/user": + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + parameters: [] + responses: + default: + description: successful operation + requestBody: + content: + application/json: + description: Created user object + schema: + "$ref": "#/components/schemas/User" + "/user/createWithArray": + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + parameters: [] + responses: + default: + description: successful operation + requestBody: + "$ref": "#/components/requestBodies/requestBody2" + "/user/createWithList": + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + parameters: [] + responses: + default: + description: successful operation + requestBody: + "$ref": "#/components/requestBodies/requestBody2" + "/user/login": + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + format: password + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + 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: '' + operationId: logoutUser + parameters: [] + responses: + default: + description: successful operation + "/user/{username}": + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: 'The name that needs to be fetched. Use user1 for testing. ' + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + "$ref": "#/components/schemas/User" + application/json: + schema: + "$ref": "#/components/schemas/User" + '400': + description: Invalid username supplied + '404': + description: User not found + "/producesTest": + get: + parameters: [] + responses: + '200': + description: it works + content: + application/json: + schema: + type: object + properties: + name: + type: string + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be updated + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + description: Updated user object + schema: + "$ref": "#/components/schemas/User" + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +components: + schemas: + RemoteSchema: + "$ref": "http://localhost:${dynamicPort}/remote/schema#/components/schemas/RemoteSchema" + VeryComplexType: + type: integer + format: int32 + ExtendedErrorModel: + allOf: + - type: object + required: + - rootCause + properties: + rootCause: + type: string + "$ref": "#/components/schemas/Category" + Order: + type: object + not: + type: integer + format: int32 + additionalProperties: + type: integer + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + OrderRef: + type: object + not: + type: integer + format: int32 + "$ref": "#/components/schemas/Category" + additionalProperties: + type: integer + "$ref": "http://localhost:${dynamicPort}/remote/schema#/components/schemas/User" + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User + User1: + type: object + xml: + name: USER + properties: + id: + type: integer + format: int32 + example: 4 + xml: + attribute: true + name: ID + name: + type: string + example: Arthur Dent + xml: + name: NAME + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + category: + "$ref": "#/components/schemas/Category" + user: + type: string + example: doggie + "$ref": "http://localhost:${dynamicPort}/remote/schema#/components/schemas/User" + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + "$ref": "http://localhost:${dynamicPort}/remote/schema#/components/schemas/ExampleSchema" + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + required: + - name + - photoUrls + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + responses: + Found: + description: Entity not found. + "$ref": "http://localhost:${dynamicPort}/remote/response#/responses/RemoteResponse" + NotFound: + description: Entity not found. + IllegalInput: + description: Illegal input for operation. + headers: + X-Ref-Limit-Limit: + "$ref": "#/components/headers/X-Rate-Limit-Reset" + links: + address: + "$ref": "#/components/links/unsubscribe" + GeneralError: + description: General Error + content: + application/json: + schema: + $ref: '#/components/schemas/ExtendedErrorModel' + parameters: + contentParameter: + in: query + name: coordinates + content: + application/json: + schema: + $ref: '#/components/schemas/ExtendedErrorModel' + examples: + cat: + summary: An example of a cat + value: + name: Fluffy + petType: Cat + color: White + gender: male + breed: Persian + refParam: + "$ref": "#/components/parameters/limitParam" + remoteParameter: + "$ref": "http://localhost:${dynamicPort}/remote/parameter" + newParam: + name: skip + in: query + description: number of items to skip + required: true + schema: + type: integer + format: int32 + "$ref": "#/components/schemas/Tag" + skipParam: + name: skip + in: query + description: number of items to skip + required: true + schema: + type: integer + format: int32 + limitParam: + name: limit + in: query + description: max records to return + required: true + schema: + type: integer + format: int32 + examples: + Trillian: + value: + id: 3 + name: Tricia McMillan + Arthur: + value: + id: 4 + name: Arthur Dent + referenceCat: + "$ref": "http://localhost:${dynamicPort}/remote/example" + cat: + summary: An example of a cat + value: + name: Fluffy + petType: Cat + color: White + gender: male + breed: Persian + dog: + summary: An example of a dog with a cat's name + value: + name: Puma + petType: Dog + color: Black + gender: Female + breed: Mixed + frog: + $ref: "#/components/examples/cat" + requestBodies: + reference: + "$ref": "http://localhost:${dynamicPort}/remote/requestBody#/requestBodies/remote_requestBody" + requestBody1: + description: request body in components + content: + application/json: + description: Pet object that needs to be added to the store + schema: + "$ref": "#/components/schemas/Pet" + application/xml: + description: Pet object that needs to be added to the store + schema: + "$ref": "#/components/schemas/Pet" + requestBody2: + content: + application/json: + description: List of user object + schema: + type: array + items: + "$ref": "#/components/schemas/User" + requestBody3: + "$ref": "#/components/requestBodies/requestBody2" + securitySchemes: + reference: + "$ref": "#/components/securitySchemes/api_key" + remote_reference: + "$ref": "http://localhost:${dynamicPort}/remote/security#/petstore_remote" + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + petstore_auth_password: + type: oauth2 + flows: + password: + tokenUrl: http://petstore.swagger.io/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + petstore_auth_clientCredentials: + type: oauth2 + flows: + clientCredentials: + tokenUrl: http://petstore.swagger.io/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + petstore_auth_authorizationCode: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: http://petstore.swagger.io/oauth/dialog + tokenUrl: http://petstore.swagger.io/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_cookie: + type: apiKey + name: api_key + in: cookie + http: + type: http + scheme: Basic + openID: + type: openIdConnect + openIdConnectUrl : http://openIdConnect.example.com + headers: + X-Ref-Limit-Limit: + "$ref": "#/components/headers/X-Rate-Limit-Reset" + X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + schema: + type: integer + example: "This is a header example" + X-Rate-Limit-Remaining: + description: The number of remaining requests in the current period + schema: + type: integer + "$ref": "http://localhost:${dynamicPort}/remote/schema#/components/schemas/User" + X-Rate-Limit-Reset: + description: The number of seconds left in the current period + content: + application/json: + schema: + $ref: '#/components/schemas/ExtendedErrorModel' + examples: + headerExample: + $ref: "#/components/examples/dog" + links: + referenced: + "$ref": "#/components/links/unsubscribe" + unsubscribe: + operationId: cancelHookCallback + parameters: + id: $response.body#/hookId + x-link: link extension + subscribe: + "$ref": "http://localhost:${dynamicPort}/remote/link" + callbacks: + remoteCallback: + "$ref": "http://localhost:${dynamicPort}/remote/callback" + referenced: + "$ref": "#/components/callbacks/failed" + heartbeat: + '$request.query.heartbeat-url': + post: + requestBody: + $ref: '#/components/requestBodies/requestBody3' + responses: + '200': + description: Consumer acknowledged the callback + failed: + '$response.body#/failedUrl': + post: + requestBody: + $ref: '#/components/requestBodies/requestBody3' + responses: + '200': + description: Consumer acknowledged the callback failed + success: + '$response.body#/successUrl': + post: + requestBody: + $ref: '#/components/requestBodies/requestBody1' + responses: + '200': + description: Consumer acknowledged the callback + x-component: + - url: http://component.swagger.io/v2/swagger.json + format: OAS + version: '3.0' + converter: + url: https://github.com/mermade/oas3 + version: 1.2.3 + x-api-title: pet store test api in components diff --git a/pom.xml b/pom.xml index 438a9d3ca2..25ec9ffc87 100644 --- a/pom.xml +++ b/pom.xml @@ -406,7 +406,7 @@ 1.0.64 2.11.0 1.7.30 - 2.2.7 + 2.2.8-SNAPSHOT 1.6.9 4.13.2 6.14.2