diff --git a/core/src/test/java/io/smallrye/openapi/runtime/io/OpenApiParserAndSerializerTest.java b/core/src/test/java/io/smallrye/openapi/runtime/io/OpenApiParserAndSerializerTest.java index b602fc3bc..70c329f06 100644 --- a/core/src/test/java/io/smallrye/openapi/runtime/io/OpenApiParserAndSerializerTest.java +++ b/core/src/test/java/io/smallrye/openapi/runtime/io/OpenApiParserAndSerializerTest.java @@ -1,10 +1,10 @@ package io.smallrye.openapi.runtime.io; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.StringReader; +import java.io.*; import java.net.URL; -import java.text.ParseException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import org.apache.commons.io.IOUtils; import org.eclipse.microprofile.openapi.models.OpenAPI; @@ -13,11 +13,17 @@ import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; +import com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException; + +import io.smallrye.openapi.api.constants.OpenApiConstants; + /** * @author eric.wittmann@gmail.com */ class OpenApiParserAndSerializerTest { + static final int REPEAT_BODY_CONTENTS_ITERATIONS = 1536; // ~8MB? + /** * Loads a resource as a string (reads the content at the URL). * @@ -69,19 +75,33 @@ private static String normalizeYaml(String yaml) { } } + private static Path generateBigStaticFile() throws IOException { + // let's build a big openapi file, start by its header + String bigFileContents = loadResource(OpenApiParserAndSerializerTest.class.getResource("openapi-fragment-header.yaml")); + // body + final String bodyChunk = loadResource(OpenApiParserAndSerializerTest.class.getResource("openapi-fragment-body.yaml")); + for (int i = 0; i < REPEAT_BODY_CONTENTS_ITERATIONS; i++) { + // n-chunk of body + bigFileContents += bodyChunk.replaceAll("@@ID@@", String.valueOf(i)); + } + // footer + bigFileContents += loadResource(OpenApiParserAndSerializerTest.class.getResource("openapi-fragment-footer.yaml")); + + Path tempFile = Files.createTempFile("sroap-big-file-test-", "-generated.yaml"); + Files.write(tempFile, bigFileContents.getBytes(StandardCharsets.UTF_8)); + return tempFile; + } + /** * Performs a full round-trip parse+serialize test on a single resource. - * - * @param resource + * + * @param testResource * @param format * @throws IOException - * @throws ParseException * @throws JSONException */ - private static void doTest(String resource, Format format) throws IOException, ParseException, JSONException { - URL testResource = OpenApiParserAndSerializerTest.class.getResource(resource); + private static void doTest(URL testResource, Format format, OpenAPI impl) throws IOException, JSONException { String original = loadResource(testResource); - OpenAPI impl = OpenApiParser.parse(testResource); String roundTrip = OpenApiSerializer.serialize(impl, format); try { @@ -98,11 +118,38 @@ private static void doTest(String resource, Format format) throws IOException, P } } + /** + * Performs a full round-trip parse+serialize test on a single resource. + * + * @param resource + * @param format + * @throws IOException + * @throws JSONException + */ + private static void doTest(String resource, Format format) throws IOException, JSONException { + URL testResource = OpenApiParserAndSerializerTest.class.getResource(resource); + OpenAPI impl = OpenApiParser.parse(testResource); + doTest(testResource, format, impl); + } + + /** + * Performs a full round-trip parse+serialize test on a single resource. + * + * @param testResource + * @param format + * @throws IOException + * @throws JSONException + */ + private static void doTest(URL testResource, Format format) throws IOException, JSONException { + OpenAPI impl = OpenApiParser.parse(testResource); + doTest(testResource, format, impl); + } + /** * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testParseSimplest() throws IOException, ParseException, JSONException { + void testParseSimplest() throws IOException, JSONException { doTest("simplest.json", Format.JSON); } @@ -110,7 +157,7 @@ void testParseSimplest() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testParseSimplestYaml() throws IOException, ParseException, JSONException { + void testParseSimplestYaml() throws IOException, JSONException { doTest("simplest.yaml", Format.YAML); } @@ -118,7 +165,7 @@ void testParseSimplestYaml() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testParseInfo() throws IOException, ParseException, JSONException { + void testParseInfo() throws IOException, JSONException { doTest("info.json", Format.JSON); } @@ -126,7 +173,7 @@ void testParseInfo() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testParseInfoYaml() throws IOException, ParseException, JSONException { + void testParseInfoYaml() throws IOException, JSONException { doTest("info.yaml", Format.YAML); } @@ -134,7 +181,7 @@ void testParseInfoYaml() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testExternalDocs() throws IOException, ParseException, JSONException { + void testExternalDocs() throws IOException, JSONException { doTest("externalDocs.json", Format.JSON); } @@ -142,7 +189,7 @@ void testExternalDocs() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testExtensions() throws IOException, ParseException, JSONException { + void testExtensions() throws IOException, JSONException { doTest("extensions.json", Format.JSON); } @@ -150,7 +197,7 @@ void testExtensions() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSecurity() throws IOException, ParseException, JSONException { + void testSecurity() throws IOException, JSONException { doTest("security.json", Format.JSON); } @@ -158,7 +205,7 @@ void testSecurity() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testServers() throws IOException, ParseException, JSONException { + void testServers() throws IOException, JSONException { doTest("servers.json", Format.JSON); } @@ -166,7 +213,7 @@ void testServers() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testServersYaml() throws IOException, ParseException, JSONException { + void testServersYaml() throws IOException, JSONException { doTest("servers.yaml", Format.YAML); } @@ -174,7 +221,7 @@ void testServersYaml() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testTags() throws IOException, ParseException, JSONException { + void testTags() throws IOException, JSONException { doTest("tags.json", Format.JSON); } @@ -182,7 +229,7 @@ void testTags() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Callbacks() throws IOException, ParseException, JSONException { + void testComponents_Callbacks() throws IOException, JSONException { doTest("components-callbacks.json", Format.JSON); } @@ -190,7 +237,7 @@ void testComponents_Callbacks() throws IOException, ParseException, JSONExceptio * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Empty() throws IOException, ParseException, JSONException { + void testComponents_Empty() throws IOException, JSONException { doTest("components-empty.json", Format.JSON); } @@ -198,7 +245,7 @@ void testComponents_Empty() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Examples() throws IOException, ParseException, JSONException { + void testComponents_Examples() throws IOException, JSONException { doTest("components-examples.json", Format.JSON); } @@ -206,7 +253,7 @@ void testComponents_Examples() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Headers() throws IOException, ParseException, JSONException { + void testComponents_Headers() throws IOException, JSONException { doTest("components-headers.json", Format.JSON); } @@ -214,7 +261,7 @@ void testComponents_Headers() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Links() throws IOException, ParseException, JSONException { + void testComponents_Links() throws IOException, JSONException { doTest("components-links.json", Format.JSON); } @@ -222,7 +269,7 @@ void testComponents_Links() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Parameters() throws IOException, ParseException, JSONException { + void testComponents_Parameters() throws IOException, JSONException { doTest("components-parameters.json", Format.JSON); } @@ -230,7 +277,7 @@ void testComponents_Parameters() throws IOException, ParseException, JSONExcepti * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_RequestBodies() throws IOException, ParseException, JSONException { + void testComponents_RequestBodies() throws IOException, JSONException { doTest("components-requestBodies.json", Format.JSON); } @@ -238,7 +285,7 @@ void testComponents_RequestBodies() throws IOException, ParseException, JSONExce * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Responses() throws IOException, ParseException, JSONException { + void testComponents_Responses() throws IOException, JSONException { doTest("components-responses.json", Format.JSON); } @@ -246,7 +293,7 @@ void testComponents_Responses() throws IOException, ParseException, JSONExceptio * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_Schemas() throws IOException, ParseException, JSONException { + void testComponents_Schemas() throws IOException, JSONException { doTest("components-schemas.json", Format.JSON); } @@ -254,7 +301,7 @@ void testComponents_Schemas() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testComponents_SecuritySchemes() throws IOException, ParseException, JSONException { + void testComponents_SecuritySchemes() throws IOException, JSONException { doTest("components-securitySchemes.json", Format.JSON); } @@ -262,7 +309,7 @@ void testComponents_SecuritySchemes() throws IOException, ParseException, JSONEx * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_AllOperations() throws IOException, ParseException, JSONException { + void testPaths_AllOperations() throws IOException, JSONException { doTest("paths-all-operations.json", Format.JSON); } @@ -270,7 +317,7 @@ void testPaths_AllOperations() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_Empty() throws IOException, ParseException, JSONException { + void testPaths_Empty() throws IOException, JSONException { doTest("paths-empty.json", Format.JSON); } @@ -278,7 +325,7 @@ void testPaths_Empty() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetCallbacks() throws IOException, ParseException, JSONException { + void testPaths_GetCallbacks() throws IOException, JSONException { doTest("paths-get-callbacks.json", Format.JSON); } @@ -286,7 +333,7 @@ void testPaths_GetCallbacks() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetParameters() throws IOException, ParseException, JSONException { + void testPaths_GetParameters() throws IOException, JSONException { doTest("paths-get-parameters.json", Format.JSON); } @@ -294,7 +341,7 @@ void testPaths_GetParameters() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetRequestBodyContent() throws IOException, ParseException, JSONException { + void testPaths_GetRequestBodyContent() throws IOException, JSONException { doTest("paths-get-requestBody-content.json", Format.JSON); } @@ -302,7 +349,7 @@ void testPaths_GetRequestBodyContent() throws IOException, ParseException, JSONE * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetRequestBodyExample() throws IOException, ParseException, JSONException { + void testPaths_GetRequestBodyExample() throws IOException, JSONException { doTest("paths-get-requestBody-example.json", Format.JSON); } @@ -310,7 +357,7 @@ void testPaths_GetRequestBodyExample() throws IOException, ParseException, JSONE * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetRequestBody() throws IOException, ParseException, JSONException { + void testPaths_GetRequestBody() throws IOException, JSONException { doTest("paths-get-requestBody.json", Format.JSON); } @@ -318,7 +365,7 @@ void testPaths_GetRequestBody() throws IOException, ParseException, JSONExceptio * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetResponseContent() throws IOException, ParseException, JSONException { + void testPaths_GetResponseContent() throws IOException, JSONException { doTest("paths-get-response-content.json", Format.JSON); } @@ -326,7 +373,7 @@ void testPaths_GetResponseContent() throws IOException, ParseException, JSONExce * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetResponseHeaders() throws IOException, ParseException, JSONException { + void testPaths_GetResponseHeaders() throws IOException, JSONException { doTest("paths-get-response-headers.json", Format.JSON); } @@ -334,7 +381,7 @@ void testPaths_GetResponseHeaders() throws IOException, ParseException, JSONExce * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetResponseLinks() throws IOException, ParseException, JSONException { + void testPaths_GetResponseLinks() throws IOException, JSONException { doTest("paths-get-response-links.json", Format.JSON); } @@ -342,7 +389,7 @@ void testPaths_GetResponseLinks() throws IOException, ParseException, JSONExcept * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetResponses() throws IOException, ParseException, JSONException { + void testPaths_GetResponses() throws IOException, JSONException { doTest("paths-get-responses.json", Format.JSON); } @@ -350,7 +397,7 @@ void testPaths_GetResponses() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetSecurity() throws IOException, ParseException, JSONException { + void testPaths_GetSecurity() throws IOException, JSONException { doTest("paths-get-security.json", Format.JSON); } @@ -358,7 +405,7 @@ void testPaths_GetSecurity() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_GetServers() throws IOException, ParseException, JSONException { + void testPaths_GetServers() throws IOException, JSONException { doTest("paths-get-servers.json", Format.JSON); } @@ -366,7 +413,7 @@ void testPaths_GetServers() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_Get() throws IOException, ParseException, JSONException { + void testPaths_Get() throws IOException, JSONException { doTest("paths-get.json", Format.JSON); } @@ -374,7 +421,7 @@ void testPaths_Get() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_Parameters() throws IOException, ParseException, JSONException { + void testPaths_Parameters() throws IOException, JSONException { doTest("paths-parameters.json", Format.JSON); } @@ -382,7 +429,7 @@ void testPaths_Parameters() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_Ref() throws IOException, ParseException, JSONException { + void testPaths_Ref() throws IOException, JSONException { doTest("paths-ref.json", Format.JSON); } @@ -390,7 +437,7 @@ void testPaths_Ref() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_Servers() throws IOException, ParseException, JSONException { + void testPaths_Servers() throws IOException, JSONException { doTest("paths-servers.json", Format.JSON); } @@ -398,7 +445,7 @@ void testPaths_Servers() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testPaths_Extensions() throws IOException, ParseException, JSONException { + void testPaths_Extensions() throws IOException, JSONException { doTest("paths-with-extensions.json", Format.JSON); } @@ -406,7 +453,7 @@ void testPaths_Extensions() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_Discriminator() throws IOException, ParseException, JSONException { + void testSchemas_Discriminator() throws IOException, JSONException { doTest("schemas-discriminator.json", Format.JSON); } @@ -414,7 +461,7 @@ void testSchemas_Discriminator() throws IOException, ParseException, JSONExcepti * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_AdditionalProperties() throws IOException, ParseException, JSONException { + void testSchemas_AdditionalProperties() throws IOException, JSONException { doTest("schemas-with-additionalProperties.json", Format.JSON); } @@ -422,7 +469,7 @@ void testSchemas_AdditionalProperties() throws IOException, ParseException, JSON * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_AllOf() throws IOException, ParseException, JSONException { + void testSchemas_AllOf() throws IOException, JSONException { doTest("schemas-with-allOf.json", Format.JSON); } @@ -430,7 +477,7 @@ void testSchemas_AllOf() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_Composition() throws IOException, ParseException, JSONException { + void testSchemas_Composition() throws IOException, JSONException { doTest("schemas-with-composition.json", Format.JSON); } @@ -438,7 +485,7 @@ void testSchemas_Composition() throws IOException, ParseException, JSONException * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_Example() throws IOException, ParseException, JSONException { + void testSchemas_Example() throws IOException, JSONException { doTest("schemas-with-example.json", Format.JSON); } @@ -446,7 +493,7 @@ void testSchemas_Example() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_ExternalDocs() throws IOException, ParseException, JSONException { + void testSchemas_ExternalDocs() throws IOException, JSONException { doTest("schemas-with-externalDocs.json", Format.JSON); } @@ -454,7 +501,7 @@ void testSchemas_ExternalDocs() throws IOException, ParseException, JSONExceptio * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_MetaData() throws IOException, ParseException, JSONException { + void testSchemas_MetaData() throws IOException, JSONException { doTest("schemas-with-metaData.json", Format.JSON); } @@ -462,7 +509,7 @@ void testSchemas_MetaData() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testSchemas_XML() throws IOException, ParseException, JSONException { + void testSchemas_XML() throws IOException, JSONException { doTest("schemas-with-xml.json", Format.JSON); } @@ -470,7 +517,7 @@ void testSchemas_XML() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testEverything() throws IOException, ParseException, JSONException { + void testEverything() throws IOException, JSONException { doTest("_everything.json", Format.JSON); } @@ -478,8 +525,32 @@ void testEverything() throws IOException, ParseException, JSONException { * Test method for {@link OpenApiParser#parse(java.net.URL)}. */ @Test - void testEverythingYaml() throws IOException, ParseException, JSONException { + void testEverythingYaml() throws IOException, JSONException { doTest("_everything.yaml", Format.YAML); } + /** + * Test method for {@link OpenApiParser#parse(java.net.URL)}. + * + * Here we check that {@link OpenApiParser#parse(java.net.URL)} throws an exception + * when a file bigger than the maximum allowed size is passed, while + * {@link OpenApiParser#parse(InputStream, Format, Integer)} is successful when using a higher limit. + */ + @Test + void testParsingBigStaticYamlFile() throws IOException, JSONException { + // let's check that parsing a file bigger than the default (3 MB) allowed by the underlying implementation + // would fail + Path tempFile = generateBigStaticFile(); + Assertions.assertThrows(JacksonYAMLParseException.class, () -> doTest(tempFile.toUri().toURL(), Format.YAML)); + // now let's set a higher limit + final Integer maximumFileSize = 8 * 1024 * 1024; + // and finally, let's parse the file but pass the custom limit + try { + try (InputStream is = new FileInputStream(tempFile.toFile())) { + doTest(tempFile.toUri().toURL(), Format.YAML, OpenApiParser.parse(is, Format.YAML, maximumFileSize)); + } + } finally { + System.clearProperty(OpenApiConstants.MAXIMUM_STATIC_FILE_SIZE); + } + } } diff --git a/core/src/test/java/io/smallrye/openapi/runtime/io/StaticFileConfigTest.java b/core/src/test/java/io/smallrye/openapi/runtime/io/StaticFileConfigTest.java index 8714b1d59..57e3cd90c 100644 --- a/core/src/test/java/io/smallrye/openapi/runtime/io/StaticFileConfigTest.java +++ b/core/src/test/java/io/smallrye/openapi/runtime/io/StaticFileConfigTest.java @@ -2,11 +2,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import java.io.IOException; - import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; -import org.json.JSONException; import org.junit.jupiter.api.Test; import io.smallrye.openapi.api.OpenApiConfig; @@ -16,11 +13,16 @@ class StaticFileConfigTest { @Test - void testSettingMaximumFileSize() throws IOException, JSONException { + void testSettingMaximumFileSize() { final Integer maximumFileSize = 8 * 1024 * 1024; System.setProperty(OpenApiConstants.MAXIMUM_STATIC_FILE_SIZE, maximumFileSize.toString()); - Config config = ConfigProvider.getConfig(); - OpenApiConfig openApiConfig = OpenApiConfigImpl.fromConfig(config); - assertEquals(maximumFileSize, openApiConfig.getMaximumStaticFileSize()); + + try { + Config config = ConfigProvider.getConfig(); + OpenApiConfig openApiConfig = OpenApiConfigImpl.fromConfig(config); + assertEquals(maximumFileSize, openApiConfig.getMaximumStaticFileSize()); + } finally { + System.clearProperty(OpenApiConstants.MAXIMUM_STATIC_FILE_SIZE); + } } } diff --git a/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-body.yaml b/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-body.yaml new file mode 100644 index 000000000..0f7cedda5 --- /dev/null +++ b/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-body.yaml @@ -0,0 +1,99 @@ + /proxys@@ID@@/all: + get: + summary: Get all @@ID@@ type proxies + description: Retrieves and returns the available proxies + operationId: getAllProxies + responses: + "200": + description: All available proxies + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ProxyEntity' + x-routing-fqdn: provider.acme.unknown + x-string-property: string-value + x-boolean-property: true + x-number-property: 42 + x-object-property: + property-1: value-1 + property-2: value-2 + property-3: + prop-3-1: 42 + prop-3-2: true + x-string-array-property: + - one + - two + - three + x-object-array-property: + - name: item-1 + - name: item-2 + /proxy@@ID@@/{code}: + get: + summary: Get @@ID@@ type proxy by code + description: Retrieves and returns the requested @@ID@@ type proxy + operationId: getProxyByCode + parameters: + - name: code + in: path + required: true + schema: + type: string + - name: excludeObsolete + in: query + schema: + type: boolean + responses: + "204": + description: Requested @@ID@@ type proxy was not found + "200": + description: Requested @@ID@@ type proxy + content: + application/json: + schema: + $ref: '#/components/schemas/ProxyEntity' + x-routing-fqdn: provider.acme.unknown + patch: + summary: Updates a @@ID@@ type proxy data + description: "Retrieves, updates and returns the requested @@ID@@ type proxy data" + operationId: updateProxy + parameters: + - name: code + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProxyEntity' + responses: + "404": + description: Requested @@ID@@ type proxy was not found + "200": + description: Updated @@ID@@ type proxy + content: + application/json: + schema: + $ref: '#/components/schemas/ProxyEntity' + example: "{\"code\": \"@@ID@@\", \"name\": \"@@ID@@ type proxy\", \"obsolete\"\ + : false}" + x-routing-fqdn: provider.acme.unknown + x-string-property: string-value + x-boolean-property: true + x-number-property: 42 + x-object-property: + property-1: value-1 + property-2: value-2 + property-3: + prop-3-1: 42 + prop-3-2: true + x-string-array-property: + - one + - two + - three + x-object-array-property: + - name: item-1 + - name: item-2 diff --git a/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-footer.yaml b/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-footer.yaml new file mode 100644 index 000000000..27c6cc32a --- /dev/null +++ b/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-footer.yaml @@ -0,0 +1,11 @@ +components: + schemas: + ProxyEntity: + type: object + properties: + code: + type: string + name: + type: string + obsolete: + type: boolean diff --git a/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-header.yaml b/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-header.yaml new file mode 100644 index 000000000..a64d58d76 --- /dev/null +++ b/core/src/test/resources/io/smallrye/openapi/runtime/io/openapi-fragment-header.yaml @@ -0,0 +1,6 @@ +--- +openapi: 3.0.0 +info: + title: Proxy App + version: "1.0" +paths: