diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaJAXRSServerCodegen.java index 90e8e6ea8b7c..7cd992c208d1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaJAXRSServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaJAXRSServerCodegen.java @@ -32,8 +32,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.URL; import java.io.File; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -154,6 +154,8 @@ static Map jaxrsPostProcessOperations(Map objs) @SuppressWarnings("unchecked") Map operations = (Map) objs.get("operations"); if (operations != null) { + String commonBaseName = null; + boolean baseNameEquals = true; @SuppressWarnings("unchecked") List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { @@ -219,6 +221,23 @@ static Map jaxrsPostProcessOperations(Map objs) } else if ("map".equals(operation.returnContainer)) { operation.returnContainer = "Map"; } + + if(commonBaseName == null) { + commonBaseName = operation.baseName; + } else if(!commonBaseName.equals(operation.baseName)) { + baseNameEquals = false; + } + } + if(baseNameEquals) { + objs.put("commonPath", commonBaseName); + } else { + for (CodegenOperation operation : ops) { + if(operation.baseName != null) { + operation.path = "/" + operation.baseName + operation.path; + operation.baseName = null; + } + } + objs.put("commonPath", null); } } return objs; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJerseyServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJerseyServerCodegen.java index d6bf317b9735..096992071bd9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJerseyServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJerseyServerCodegen.java @@ -159,7 +159,7 @@ public Map postProcessModelsEnum(Map objs) { @Override public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { if (useTags) { - String basePath = resourcePath; + String basePath = tag.toLowerCase(); if (basePath.startsWith("/")) { basePath = basePath.substring(1); } @@ -168,11 +168,17 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera basePath = basePath.substring(0, pos); } - if (co.path.startsWith("/" + basePath)) { + boolean pathStartsWithBasePath = co.path.startsWith("/" + basePath); + if (pathStartsWithBasePath) { co.path = co.path.substring(("/" + basePath).length()); } co.subresourceOperation = !co.path.isEmpty(); super.addOperationToGroup(tag, resourcePath, operation, co, operations); + if (pathStartsWithBasePath) { + co.baseName = basePath; + } else { + co.baseName = null; + } } else { String basePath = resourcePath; if (basePath.startsWith("/")) { diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache index d4542532e290..e9d909539f85 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache @@ -28,7 +28,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; {{/useBeanValidation}} -@Path("/{{{baseName}}}") +{{#commonPath}}@Path("/{{{commonPath}}}"){{/commonPath}}{{^commonPath}}@Path(""){{/commonPath}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @io.swagger.annotations.Api(description = "the {{{baseName}}} API") diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java index 683176dbc2c7..326e0ded8203 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java @@ -5,7 +5,12 @@ import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.servers.Server; +import org.openapitools.codegen.MockDefaultGenerator.WrittenTemplateBasedFile; +import org.testng.Assert; + +import java.io.File; import java.util.Collections; +import java.util.Optional; public class TestUtils { @@ -24,4 +29,11 @@ public static OpenAPI createOpenAPI() { openAPI.setServers(Collections.singletonList(server)); return openAPI; } + + public static WrittenTemplateBasedFile getTemplateBasedFile(MockDefaultGenerator generator, File root, String filename) { + String defaultApiFilename = new File(root, filename).getAbsolutePath().replace("\\", "/"); + Optional optional = generator.getTemplateBasedFiles().stream().filter(f -> defaultApiFilename.equals(f.getOutputFilename())).findFirst(); + Assert.assertTrue(optional.isPresent()); + return optional.get(); + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index 72b8b11bf4f5..f1970ed95986 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -44,6 +44,7 @@ import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.MockDefaultGenerator; import org.openapitools.codegen.MockDefaultGenerator.WrittenTemplateBasedFile; +import org.openapitools.codegen.TestUtils; import org.openapitools.codegen.config.CodegenConfigurator; import org.openapitools.codegen.languages.JavaClientCodegen; import org.openapitools.codegen.utils.ModelUtils; @@ -59,7 +60,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.stream.Collectors; public class JavaClientCodegenTest { @@ -406,9 +406,8 @@ public void testGeneratePing() throws Exception { String defaultApiConent = generatedFiles.get(defaultApiFilename); Assert.assertTrue(defaultApiConent.contains("public class DefaultApi")); - Optional optional = generator.getTemplateBasedFiles().stream().filter(f -> defaultApiFilename.equals(f.getOutputFilename())).findFirst(); - Assert.assertTrue(optional.isPresent()); - Assert.assertEquals(optional.get().getTemplateData().get("classname"), "DefaultApi"); + WrittenTemplateBasedFile templateBasedFile = TestUtils.getTemplateBasedFile(generator, output, "src/main/java/xyz/abcdef/api/DefaultApi.java"); + Assert.assertEquals(templateBasedFile.getTemplateData().get("classname"), "DefaultApi"); output.deleteOnExit(); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJerseyServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJerseyServerCodegenTest.java new file mode 100644 index 000000000000..fc26142c2e7c --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJerseyServerCodegenTest.java @@ -0,0 +1,251 @@ +package org.openapitools.codegen.java.jaxrs; + +import io.swagger.parser.OpenAPIParser; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.servers.Server; +import io.swagger.v3.parser.core.models.ParseOptions; + +import org.openapitools.codegen.ClientOptInput; +import org.openapitools.codegen.ClientOpts; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.CodegenOperation; +import org.openapitools.codegen.MockDefaultGenerator; +import org.openapitools.codegen.MockDefaultGenerator.WrittenTemplateBasedFile; +import org.openapitools.codegen.TestUtils; +import org.openapitools.codegen.languages.JavaJerseyServerCodegen; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.io.File; +import java.nio.file.Files; +import java.util.List; +import java.util.Map; + +public class JavaJerseyServerCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); + codegen.processOpts(); + + OpenAPI openAPI = new OpenAPI(); + openAPI.addServersItem(new Server().url("https://api.abcde.xy:8082/v2")); + codegen.preprocessOpenAPI(openAPI); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + Assert.assertEquals(codegen.modelPackage(), "org.openapitools.model"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "org.openapitools.model"); + Assert.assertEquals(codegen.apiPackage(), "org.openapitools.api"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "org.openapitools.api"); + Assert.assertEquals(codegen.getInvokerPackage(), "org.openapitools.api"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "org.openapitools.api"); + Assert.assertEquals(codegen.additionalProperties().get(JavaJerseyServerCodegen.SERVER_PORT), "8082"); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); + codegen.setHideGenerationTimestamp(true); + codegen.setModelPackage("xx.yyyyyyyy.model"); + codegen.setApiPackage("xx.yyyyyyyy.api"); + codegen.setInvokerPackage("xx.yyyyyyyy.invoker"); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + Assert.assertEquals(codegen.modelPackage(), "xx.yyyyyyyy.model"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xx.yyyyyyyy.model"); + Assert.assertEquals(codegen.apiPackage(), "xx.yyyyyyyy.api"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xx.yyyyyyyy.api"); + Assert.assertEquals(codegen.getInvokerPackage(), "xx.yyyyyyyy.invoker"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xx.yyyyyyyy.invoker"); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true"); + codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.mmmmm.model"); + codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.aaaaa.api"); + codegen.additionalProperties().put(CodegenConstants.INVOKER_PACKAGE,"xyz.yyyyy.iiii.invoker"); + codegen.additionalProperties().put("serverPort","8088"); + codegen.processOpts(); + + OpenAPI openAPI = new OpenAPI(); + openAPI.addServersItem(new Server().url("https://api.abcde.xy:8082/v2")); + codegen.preprocessOpenAPI(openAPI); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.mmmmm.model"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xyz.yyyyy.mmmmm.model"); + Assert.assertEquals(codegen.apiPackage(), "xyz.yyyyy.aaaaa.api"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xyz.yyyyy.aaaaa.api"); + Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.iiii.invoker"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.iiii.invoker"); + Assert.assertEquals(codegen.additionalProperties().get(JavaJerseyServerCodegen.SERVER_PORT), "8088"); + } + + @Test + public void testAddOperationToGroupUseTagsFalse() throws Exception { + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/tags.yaml", null, new ParseOptions()).getOpenAPI(); + JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); + codegen.setUseTags(false); + codegen.setOutputDir(output.getAbsolutePath()); + + ClientOpts opts = new ClientOpts(); + ClientOptInput input = new ClientOptInput(); + input.setOpenAPI(openAPI); + input.setConfig(codegen); + input.setOpts(opts); + + MockDefaultGenerator generator = new MockDefaultGenerator(); + generator.opts(input).generate(); + + WrittenTemplateBasedFile group1File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group1Api.java"); + Assert.assertEquals(group1File.getTemplateData().get("baseName"), "group1"); + Assert.assertEquals(group1File.getTemplateData().get("commonPath"), "group1"); + List group1 = getOperationsList(group1File.getTemplateData()); + Assert.assertEquals(group1.size(), 2); + Assert.assertEquals(group1.get(0).path, "/op1"); + Assert.assertEquals(group1.get(0).baseName, "group1"); + Assert.assertEquals(group1.get(0).subresourceOperation, true); + Assert.assertEquals(group1.get(1).path, "/op2"); + Assert.assertEquals(group1.get(1).baseName, "group1"); + Assert.assertEquals(group1.get(1).subresourceOperation, true); + + WrittenTemplateBasedFile group2File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group2Api.java"); + Assert.assertEquals(group2File.getTemplateData().get("baseName"), "group2"); + Assert.assertEquals(group2File.getTemplateData().get("commonPath"), "group2"); + List group2 = getOperationsList(group2File.getTemplateData()); + Assert.assertEquals(group2.size(), 1); + Assert.assertEquals(group2.get(0).path, "/op3"); + Assert.assertEquals(group2.get(0).baseName, "group2"); + Assert.assertEquals(group2.get(0).subresourceOperation, true); + + WrittenTemplateBasedFile group3File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group3Api.java"); + Assert.assertEquals(group3File.getTemplateData().get("baseName"), "group3"); + Assert.assertEquals(group3File.getTemplateData().get("commonPath"), "group3"); + List group3 = getOperationsList(group3File.getTemplateData()); + Assert.assertEquals(group3.size(), 1); + Assert.assertEquals(group3.get(0).path, "/op4"); + Assert.assertEquals(group3.get(0).baseName, "group3"); + Assert.assertEquals(group3.get(0).subresourceOperation, true); + + WrittenTemplateBasedFile group4File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group4Api.java"); + Assert.assertEquals(group4File.getTemplateData().get("baseName"), "group4"); + Assert.assertEquals(group4File.getTemplateData().get("commonPath"), "group4"); + List group4 = getOperationsList(group4File.getTemplateData()); + Assert.assertEquals(group4.size(), 2); + Assert.assertEquals(group4.get(0).path, "/op5"); + Assert.assertEquals(group4.get(0).baseName, "group4"); + Assert.assertEquals(group4.get(0).subresourceOperation, true); + Assert.assertEquals(group4.get(1).path, "/op6"); + Assert.assertEquals(group4.get(1).baseName, "group4"); + Assert.assertEquals(group4.get(1).subresourceOperation, true); + + WrittenTemplateBasedFile group5File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group5Api.java"); + Assert.assertEquals(group5File.getTemplateData().get("baseName"), "group5"); + Assert.assertEquals(group5File.getTemplateData().get("commonPath"), "group5"); + List group5 = getOperationsList(group5File.getTemplateData()); + Assert.assertEquals(group5.size(), 1); + Assert.assertEquals(group5.get(0).path, "/op7"); + Assert.assertEquals(group5.get(0).baseName, "group5"); + Assert.assertEquals(group5.get(0).subresourceOperation, true); + + WrittenTemplateBasedFile group6File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group6Api.java"); + Assert.assertEquals(group6File.getTemplateData().get("baseName"), "group6"); + Assert.assertEquals(group6File.getTemplateData().get("commonPath"), "group6"); + List group6 = getOperationsList(group6File.getTemplateData()); + Assert.assertEquals(group6.size(), 1); + Assert.assertEquals(group6.get(0).path, "/op8"); + Assert.assertEquals(group6.get(0).baseName, "group6"); + Assert.assertEquals(group6.get(0).subresourceOperation, true); + } + + @Test + public void testAddOperationToGroupUseTagsTrue() throws Exception { + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/tags.yaml", null, new ParseOptions()).getOpenAPI(); + JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen(); + codegen.setUseTags(true); + codegen.setOutputDir(output.getAbsolutePath()); + + ClientOpts opts = new ClientOpts(); + ClientOptInput input = new ClientOptInput(); + input.setOpenAPI(openAPI); + input.setConfig(codegen); + input.setOpts(opts); + + MockDefaultGenerator generator = new MockDefaultGenerator(); + generator.opts(input).generate(); + + WrittenTemplateBasedFile tag1File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Tag1Api.java"); + Assert.assertEquals(tag1File.getTemplateData().get("baseName"), "Tag1"); + Assert.assertEquals(tag1File.getTemplateData().get("commonPath"), null); + List tag1List = getOperationsList(tag1File.getTemplateData()); + Assert.assertEquals(tag1List.size(), 1); + Assert.assertEquals(tag1List.get(0).path, "/group1/op1"); + Assert.assertEquals(tag1List.get(0).baseName, null); + Assert.assertEquals(tag1List.get(0).subresourceOperation, true); + + WrittenTemplateBasedFile tag2File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Tag2Api.java"); + Assert.assertEquals(tag2File.getTemplateData().get("baseName"), "Tag2"); + Assert.assertEquals(tag2File.getTemplateData().get("commonPath"), null); + List tag2List = getOperationsList(tag2File.getTemplateData()); + Assert.assertEquals(tag2List.size(), 2); + Assert.assertEquals(tag2List.get(0).path, "/group1/op2"); + Assert.assertEquals(tag2List.get(0).baseName, null); + Assert.assertEquals(tag2List.get(0).subresourceOperation, true); + Assert.assertEquals(tag2List.get(1).path, "/group2/op3"); + Assert.assertEquals(tag2List.get(1).baseName, null); + Assert.assertEquals(tag2List.get(1).subresourceOperation, true); + + WrittenTemplateBasedFile defaultFile = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/DefaultApi.java"); + Assert.assertEquals(defaultFile.getTemplateData().get("baseName"), "Default"); + Assert.assertEquals(defaultFile.getTemplateData().get("commonPath"), null); + List defaultList = getOperationsList(defaultFile.getTemplateData()); + Assert.assertEquals(defaultList.size(), 1); + Assert.assertEquals(defaultList.get(0).path, "/group3/op4"); + Assert.assertEquals(defaultList.get(0).baseName, null); + Assert.assertEquals(defaultList.get(0).subresourceOperation, true); + + WrittenTemplateBasedFile group4File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group4Api.java"); + Assert.assertEquals(group4File.getTemplateData().get("baseName"), "Group4"); + Assert.assertEquals(group4File.getTemplateData().get("commonPath"), "group4"); + List group4List = getOperationsList(group4File.getTemplateData()); + Assert.assertEquals(group4List.size(), 2); + Assert.assertEquals(group4List.get(0).path, "/op5"); + Assert.assertEquals(group4List.get(0).baseName, "group4"); + Assert.assertEquals(group4List.get(0).subresourceOperation, true); + Assert.assertEquals(group4List.get(1).path, "/op6"); + Assert.assertEquals(group4List.get(1).baseName, "group4"); + Assert.assertEquals(group4List.get(1).subresourceOperation, true); + + WrittenTemplateBasedFile group5File = TestUtils.getTemplateBasedFile(generator, output, "src/gen/java/org/openapitools/api/Group5Api.java"); + Assert.assertEquals(group5File.getTemplateData().get("baseName"), "Group5"); + Assert.assertEquals(group5File.getTemplateData().get("commonPath"), null); + List group5List = getOperationsList(group5File.getTemplateData()); + Assert.assertEquals(group5List.size(), 2); + Assert.assertEquals(group5List.get(0).path, "/group5/op7"); + Assert.assertEquals(group5List.get(0).baseName, null); + Assert.assertEquals(group5List.get(0).subresourceOperation, true); + Assert.assertEquals(group5List.get(1).path, "/group6/op8"); + Assert.assertEquals(group5List.get(1).baseName, null); + Assert.assertEquals(group5List.get(1).subresourceOperation, true); + } + + @SuppressWarnings("unchecked") + private List getOperationsList(Map templateData) { + Assert.assertTrue(templateData.get("operations") instanceof Map); + Map operations = (Map) templateData.get("operations"); + Assert.assertTrue(operations.get("operation") instanceof List); + return (List) operations.get("operation"); + } +} diff --git a/modules/openapi-generator/src/test/resources/3_0/tags.yaml b/modules/openapi-generator/src/test/resources/3_0/tags.yaml new file mode 100644 index 000000000000..a322f293338f --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/tags.yaml @@ -0,0 +1,78 @@ +openapi: 3.0.1 +info: + title: OpenAPI Test API + description: Tags Test + version: 1.0.0 +servers: + - url: 'http://api.company.xyz/v2' +paths: + /group1/op1: + get: + tags: + - tag1 + operationId: op1 + responses: + '200': + description: Ok + /group1/op2: + get: + tags: + - tag2 + operationId: op2 + responses: + '200': + description: Ok + /group2/op3: + get: + tags: + - tag2 + operationId: op3 + responses: + '200': + description: Ok + /group3/op4: + get: + operationId: op4 + responses: + '200': + description: Ok + /group4/op5: + get: + tags: + - group4 + operationId: op5 + responses: + '200': + description: Ok + /group4/op6: + get: + tags: + - group4 + operationId: op6 + responses: + '200': + description: Ok + /group5/op7: + get: + tags: + - group5 + operationId: op7 + responses: + '200': + description: Ok + /group6/op8: + get: + tags: + - group5 + operationId: op8 + responses: + '200': + description: Ok +# Section bellow is requested because of issue #436 +components: + schemas: + SomeObj: + type: object + properties: + someProp: + type: string \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java index 58b1843fd445..f466cddbf293 100644 --- a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java @@ -35,7 +35,7 @@ public class AnotherFakeApi { private final AnotherFakeApiService delegate = AnotherFakeApiServiceFactory.getAnotherFakeApi(); @PATCH - @Path("/dummy") + @Path("/another-fake/dummy") @Consumes({ "application/json" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "To test special tags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?" }) diff --git a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java index c0a0c3d56ad1..f20eb5506cd4 100644 --- a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java +++ b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java @@ -35,7 +35,7 @@ public class FakeClassnameTags123Api { private final FakeClassnameTags123ApiService delegate = FakeClassnameTags123ApiServiceFactory.getFakeClassnameTags123Api(); @PATCH - + @Path("/fake_classname_test") @Consumes({ "application/json" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "To test class name in snake case", notes = "To test class name in snake case", response = Client.class, authorizations = { diff --git a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java index 9251d6cb63d0..016e3761bf05 100644 --- a/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey1-useTags/src/gen/java/org/openapitools/api/PetApi.java @@ -55,7 +55,7 @@ public Response addPet( return delegate.addPet(pet,securityContext); } @DELETE - @Path("/{petId}") + @Path("/pet/{petId}") @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { @@ -74,7 +74,7 @@ public Response deletePet( return delegate.deletePet(petId,apiKey,securityContext); } @GET - @Path("/findByStatus") + @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -93,7 +93,7 @@ public Response findPetsByStatus( return delegate.findPetsByStatus(status,securityContext); } @GET - @Path("/findByTags") + @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -112,7 +112,7 @@ public Response findPetsByTags( return delegate.findPetsByTags(tags,securityContext); } @GET - @Path("/{petId}") + @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -149,7 +149,7 @@ public Response updatePet( return delegate.updatePet(pet,securityContext); } @POST - @Path("/{petId}") + @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { @@ -169,7 +169,7 @@ public Response updatePetWithForm( return delegate.updatePetWithForm(petId,name,status,securityContext); } @POST - @Path("/{petId}/uploadImage") + @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @@ -190,7 +190,7 @@ public Response uploadFile( return delegate.uploadFile(petId,additionalMetadata,inputStream, fileDetail,securityContext); } @POST - @Path("/{petId}/uploadImageWithRequiredFile") + @Path("/fake/{petId}/uploadImageWithRequiredFile") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "uploads an image (required)", notes = "", response = ModelApiResponse.class, authorizations = { diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java index 75f9f8f6e18d..4336bd462a9f 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java @@ -25,7 +25,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; -@Path("/AnotherFake") +@Path("") @io.swagger.annotations.Api(description = "the AnotherFake API") @@ -55,7 +55,7 @@ public AnotherFakeApi(@Context ServletConfig servletContext) { } @PATCH - @Path("/dummy") + @Path("/another-fake/dummy") @Consumes({ "application/json" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "To test special tags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", }) diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeApi.java index 91439b3e8ab9..bfa53bb38848 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeApi.java @@ -31,7 +31,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; -@Path("/Fake") +@Path("/fake") @io.swagger.annotations.Api(description = "the Fake API") diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java index d44d2063c079..a04fbb8fbc0c 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java @@ -25,7 +25,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; -@Path("/FakeClassnameTags123") +@Path("") @io.swagger.annotations.Api(description = "the FakeClassnameTags123 API") @@ -55,7 +55,7 @@ public FakeClassnameTags123Api(@Context ServletConfig servletContext) { } @PATCH - + @Path("/fake_classname_test") @Consumes({ "application/json" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "To test class name in snake case", notes = "To test class name in snake case", response = Client.class, authorizations = { diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java index 810cd35f38f6..0293ec5520f9 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; -@Path("/Pet") +@Path("") @io.swagger.annotations.Api(description = "the Pet API") @@ -74,7 +74,7 @@ public Response addPet(@ApiParam(value = "Pet object that needs to be added to t return delegate.addPet(pet,securityContext); } @DELETE - @Path("/{petId}") + @Path("/pet/{petId}") @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { @@ -92,7 +92,7 @@ public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @P return delegate.deletePet(petId,apiKey,securityContext); } @GET - @Path("/findByStatus") + @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -111,7 +111,7 @@ public Response findPetsByStatus(@ApiParam(value = "Status values that need to b return delegate.findPetsByStatus(status,securityContext); } @GET - @Path("/findByTags") + @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -130,7 +130,7 @@ public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=tr return delegate.findPetsByTags(tags,securityContext); } @GET - @Path("/{petId}") + @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -169,7 +169,7 @@ public Response updatePet(@ApiParam(value = "Pet object that needs to be added t return delegate.updatePet(pet,securityContext); } @POST - @Path("/{petId}") + @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { @@ -188,7 +188,7 @@ public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be return delegate.updatePetWithForm(petId,name,status,securityContext); } @POST - @Path("/{petId}/uploadImage") + @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @@ -209,7 +209,7 @@ public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext); } @POST - @Path("/{petId}/uploadImageWithRequiredFile") + @Path("/fake/{petId}/uploadImageWithRequiredFile") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "uploads an image (required)", notes = "", response = ModelApiResponse.class, authorizations = { diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/StoreApi.java index cb74fda31081..0922fe72a2c9 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/StoreApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; -@Path("/Store") +@Path("/store") @io.swagger.annotations.Api(description = "the Store API") diff --git a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/UserApi.java b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/UserApi.java index a99d03e8d3e3..52278201f1b2 100644 --- a/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/UserApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.*; import javax.validation.constraints.*; -@Path("/User") +@Path("/user") @io.swagger.annotations.Api(description = "the User API")