Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subResourcePath when using tags in java-jersey #215

Merged
merged 4 commits into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
if (useTags) {
String basePath = resourcePath;
if (basePath.startsWith("/")) {
basePath = basePath.substring(1);
}
int pos = basePath.indexOf("/");
if (pos > 0) {
basePath = basePath.substring(0, pos);
}

if (co.path.startsWith("/" + basePath)) {
co.path = co.path.substring(("/" + basePath).length());
}
co.subresourceOperation = !co.path.isEmpty();
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
} else {
String basePath = resourcePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AnotherFakeApi {
private final AnotherFakeApiService delegate = AnotherFakeApiServiceFactory.getAnotherFakeApi();

@PATCH

@Path("/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?" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class FakeApi {
private final FakeApiService delegate = FakeApiServiceFactory.getFakeApi();

@POST

@Path("/outer/boolean")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", })
Expand All @@ -54,7 +54,7 @@ public Response fakeOuterBooleanSerialize(
return delegate.fakeOuterBooleanSerialize(body,securityContext);
}
@POST

@Path("/outer/composite")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
Expand All @@ -67,7 +67,7 @@ public Response fakeOuterCompositeSerialize(
return delegate.fakeOuterCompositeSerialize(outerComposite,securityContext);
}
@POST

@Path("/outer/number")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
Expand All @@ -80,7 +80,7 @@ public Response fakeOuterNumberSerialize(
return delegate.fakeOuterNumberSerialize(body,securityContext);
}
@POST

@Path("/outer/string")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
Expand All @@ -93,7 +93,7 @@ public Response fakeOuterStringSerialize(
return delegate.fakeOuterStringSerialize(body,securityContext);
}
@PUT

@Path("/body-with-query-params")
@Consumes({ "application/json" })

@io.swagger.annotations.ApiOperation(value = "", notes = "", response = Void.class, tags={ "fake", })
Expand Down Expand Up @@ -171,7 +171,7 @@ public Response testEnumParameters(
return delegate.testEnumParameters(enumHeaderStringArray,enumHeaderString,enumQueryStringArray,enumQueryString,enumQueryInteger,enumQueryDouble,enumFormStringArray,enumFormString,securityContext);
}
@POST

@Path("/inline-additionalProperties")
@Consumes({ "application/json" })

@io.swagger.annotations.ApiOperation(value = "test inline additionalProperties", notes = "", response = Void.class, tags={ "fake", })
Expand All @@ -184,7 +184,7 @@ public Response testInlineAdditionalProperties(
return delegate.testInlineAdditionalProperties(requestBody,securityContext);
}
@GET

@Path("/jsonFormData")
@Consumes({ "application/x-www-form-urlencoded" })

@io.swagger.annotations.ApiOperation(value = "test json serialization of form data", notes = "", response = Void.class, tags={ "fake" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Response addPet(
return delegate.addPet(pet,securityContext);
}
@DELETE

@Path("/{petId}")


@io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
Expand All @@ -74,7 +74,7 @@ public Response deletePet(
return delegate.deletePet(petId,apiKey,securityContext);
}
@GET

@Path("/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 = {
Expand All @@ -93,7 +93,7 @@ public Response findPetsByStatus(
return delegate.findPetsByStatus(status,securityContext);
}
@GET

@Path("/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 = {
Expand All @@ -112,7 +112,7 @@ public Response findPetsByTags(
return delegate.findPetsByTags(tags,securityContext);
}
@GET

@Path("/{petId}")

@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
Expand Down Expand Up @@ -149,7 +149,7 @@ public Response updatePet(
return delegate.updatePet(pet,securityContext);
}
@POST

@Path("/{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 = {
Expand All @@ -169,7 +169,7 @@ public Response updatePetWithForm(
return delegate.updatePetWithForm(petId,name,status,securityContext);
}
@POST

@Path("/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class StoreApi {
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();

@DELETE

@Path("/order/{order_id}")


@io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class, tags={ "store", })
Expand All @@ -50,7 +50,7 @@ public Response deleteOrder(
return delegate.deleteOrder(orderId,securityContext);
}
@GET

@Path("/inventory")

@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
Expand All @@ -64,7 +64,7 @@ public Response getInventory(
return delegate.getInventory(securityContext);
}
@GET

@Path("/order/{order_id}")

@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
Expand All @@ -79,7 +79,7 @@ public Response getOrderById(
return delegate.getOrderById(orderId,securityContext);
}
@POST

@Path("/order")

@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Response createUser(
return delegate.createUser(user,securityContext);
}
@POST

@Path("/createWithArray")


@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", })
Expand All @@ -62,7 +62,7 @@ public Response createUsersWithArrayInput(
return delegate.createUsersWithArrayInput(user,securityContext);
}
@POST

@Path("/createWithList")


@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", })
Expand All @@ -75,7 +75,7 @@ public Response createUsersWithListInput(
return delegate.createUsersWithListInput(user,securityContext);
}
@DELETE

@Path("/{username}")


@io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", })
Expand All @@ -89,7 +89,7 @@ public Response deleteUser(
return delegate.deleteUser(username,securityContext);
}
@GET

@Path("/{username}")

@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", })
Expand All @@ -104,7 +104,7 @@ public Response getUserByName(
return delegate.getUserByName(username,securityContext);
}
@GET

@Path("/login")

@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", })
Expand All @@ -119,7 +119,7 @@ public Response loginUser(
return delegate.loginUser(username,password,securityContext);
}
@GET

@Path("/logout")


@io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", })
Expand All @@ -131,7 +131,7 @@ public Response logoutUser(
return delegate.logoutUser(securityContext);
}
@PUT

@Path("/{username}")


@io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
}

@PATCH

@Path("/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?", })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public FakeApi(@Context ServletConfig servletContext) {
}

@POST

@Path("/outer/boolean")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", })
Expand All @@ -73,7 +73,7 @@ public Response fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as po
return delegate.fakeOuterBooleanSerialize(body,securityContext);
}
@POST

@Path("/outer/composite")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
Expand All @@ -85,7 +85,7 @@ public Response fakeOuterCompositeSerialize(@ApiParam(value = "Input composite a
return delegate.fakeOuterCompositeSerialize(outerComposite,securityContext);
}
@POST

@Path("/outer/number")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
Expand All @@ -97,7 +97,7 @@ public Response fakeOuterNumberSerialize(@ApiParam(value = "Input number as post
return delegate.fakeOuterNumberSerialize(body,securityContext);
}
@POST

@Path("/outer/string")

@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
Expand All @@ -109,7 +109,7 @@ public Response fakeOuterStringSerialize(@ApiParam(value = "Input string as post
return delegate.fakeOuterStringSerialize(body,securityContext);
}
@PUT

@Path("/body-with-query-params")
@Consumes({ "application/json" })

@io.swagger.annotations.ApiOperation(value = "", notes = "", response = Void.class, tags={ "fake", })
Expand Down Expand Up @@ -186,7 +186,7 @@ public Response testEnumParameters(@ApiParam(value = "Header parameter enum test
return delegate.testEnumParameters(enumHeaderStringArray,enumHeaderString,enumQueryStringArray,enumQueryString,enumQueryInteger,enumQueryDouble,enumFormStringArray,enumFormString,securityContext);
}
@POST

@Path("/inline-additionalProperties")
@Consumes({ "application/json" })

@io.swagger.annotations.ApiOperation(value = "test inline additionalProperties", notes = "", response = Void.class, tags={ "fake", })
Expand All @@ -198,7 +198,7 @@ public Response testInlineAdditionalProperties(@ApiParam(value = "request body"
return delegate.testInlineAdditionalProperties(requestBody,securityContext);
}
@GET

@Path("/jsonFormData")
@Consumes({ "application/x-www-form-urlencoded" })

@io.swagger.annotations.ApiOperation(value = "test json serialization of form data", notes = "", response = Void.class, tags={ "fake", })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")


@io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
Expand All @@ -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")

@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 = {
Expand All @@ -111,7 +111,7 @@ public Response findPetsByStatus(@ApiParam(value = "Status values that need to b
return delegate.findPetsByStatus(status,securityContext);
}
@GET

@Path("/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 = {
Expand All @@ -130,7 +130,7 @@ public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=tr
return delegate.findPetsByTags(tags,securityContext);
}
@GET

@Path("/{petId}")

@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
Expand Down Expand Up @@ -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}")
@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 = {
Expand All @@ -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")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
Expand Down
Loading