-
Notifications
You must be signed in to change notification settings - Fork 7
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
Cloud provides response type change recipe? #18
Comments
hi @stevenniu9527 ; thanks for reporting here! Indeed right now the recipe does a simple removal rewrite-openapi/src/main/resources/META-INF/rewrite/swagger-2.yml Lines 128 to 130 in 178666d
To go from the before to after scenario you've described we'd need to add a dedicated recipe that adds the new replacement rewrite-openapi/src/main/java/org/openrewrite/openapi/swagger/ConvertApiResponseCodesToStrings.java Lines 50 to 79 in 178666d
And perhaps good to check: are you certain that change is necessary? What's default without that additional property? |
I think the return type @GET
@Path("/{username}")
@Operation(summary = "Get user by user name",
responses = {
@ApiResponse(description = "The user",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = "400", description = "User not found")})
public Response getUserByName(
@Parameter(description = "The name that needs to be fetched. Use user1 for testing. ", required = true) @PathParam("username") String username)
throws ApiException {
User user = userData.findUserByName(username);
if (null != user) {
return Response.ok().entity(user).build();
} else {
throw new NotFoundException(404, "User not found");
}
} The output for Example 2 would be: /user/{username}:
get:
summary: Get user by user name
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:
default:
description: The user
content:
application/json:
schema:
$ref: '#/components/schemas/User'
400:
description: User not found |
That's helpful info, thanks! Would you be willing and able to help create that recipe? |
I have tried the existing recipe. Now the recipe MigrateApiOperationToOperation directly deletes the response without change.
How to Migrate from Swagger to OpenAPI, Get the replacement below. Especially reserve the reponse type
@ApiOperation(value = "acquireSyncLeader", notes = "acquireSyncLeader", response = String.class, httpMethod = "GET")
i hope after migrate :
@Operation(summary = "acquireSyncLeader", description = "acquireSyncLeader", responses = {@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = String.class))),
The text was updated successfully, but these errors were encountered: