Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !11755

[jaxrs-cxf-cdi] mark deprecated api methods

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/selliera/master into master 3 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 4

Created by: selliera

In the generated java code, it is usefull to have the generated java api use the @Deprecated annotation. This enable to leverage this annotation at runtime to trigger specific logging for instance.

In the generated interface, use the @Deprecated annotation. Also, in the jax-rs implementation that links the jax-rs api with the cdi bean implementing the interface, use the @SuppressWarnings("deprecation") annotation. This way the deprecation warning is not shown in generated code.

One can use the interface as before: the java compiler can then tell which implementations do implement a deprecated api, using a warning. If the implementation itself also sets the @Deprecated annotation, then there is no warning, unless the implementation is called at another place in the code.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10)

Compare
  • master (base)

and
  • latest version
    a2916e94
    1 commit, 2 years ago

4 files
+ 5
- 3

    Preferences

    File browser
    Compare changes
modules/…/…/‎…/…/…/cxf-cdi‎
api.mu‎stache‎ +2 -1
apiServic‎e.mustache‎ +1 -1
samples/server/…‎/…/…/…/…/…/…/api‎
PetAp‎i.java‎ +1 -0
PetApiSer‎vice.java‎ +1 -1
modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/api.mustache
+ 2
- 1
  • View file @ a2916e94

  • Edit in single-file editor

  • Open in Web IDE


@@ -44,7 +44,8 @@ public class {{classname}} {
@@ -44,7 +44,8 @@ public class {{classname}} {
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnBaseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#isDeprecated}}@SuppressWarnings("deprecation")
 
{{/isDeprecated}}@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnBaseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#authMethods}}{{#isOAuth}}@Authorization(value = "{{name}}", scopes = {
{{#authMethods}}{{#isOAuth}}@Authorization(value = "{{name}}", scopes = {
{{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}},
{{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}},
{{/-last}}{{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}}
{{/-last}}{{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}}
modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/apiService.mustache
+ 1
- 1
  • View file @ a2916e94

  • Edit in single-file editor

  • Open in Web IDE


@@ -20,7 +20,7 @@ import javax.ws.rs.core.SecurityContext;
@@ -20,7 +20,7 @@ import javax.ws.rs.core.SecurityContext;
{{#operations}}
{{#operations}}
public interface {{classname}}Service {
public interface {{classname}}Service {
{{#operation}}
{{#operation}}
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext);
{{#isDeprecated}}@Deprecated {{/isDeprecated}}public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext);
{{/operation}}
{{/operation}}
}
}
{{/operations}}
{{/operations}}
samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/api/PetApi.java
+ 1
- 0
  • View file @ a2916e94

  • Edit in single-file editor

  • Open in Web IDE


@@ -87,6 +87,7 @@ public class PetApi {
@@ -87,6 +87,7 @@ public class PetApi {
@Path("/findByTags")
@Path("/findByTags")
@Produces({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
 
@SuppressWarnings("deprecation")
@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 = {
@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 = {
@Authorization(value = "petstore_auth", scopes = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/api/PetApiService.java
+ 1
- 1
  • View file @ a2916e94

  • Edit in single-file editor

  • Open in Web IDE


@@ -22,7 +22,7 @@ public interface PetApiService {
@@ -22,7 +22,7 @@ public interface PetApiService {
public Response addPet(Pet body, SecurityContext securityContext);
public Response addPet(Pet body, SecurityContext securityContext);
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext);
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext);
public Response findPetsByStatus(List<String> status, SecurityContext securityContext);
public Response findPetsByStatus(List<String> status, SecurityContext securityContext);
public Response findPetsByTags(List<String> tags, SecurityContext securityContext);
@Deprecated public Response findPetsByTags(List<String> tags, SecurityContext securityContext);
public Response getPetById(Long petId, SecurityContext securityContext);
public Response getPetById(Long petId, SecurityContext securityContext);
public Response updatePet(Pet body, SecurityContext securityContext);
public Response updatePet(Pet body, SecurityContext securityContext);
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext);
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext);
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: firstcontributions/frontend!1
Source branch: github/fork/selliera/master

Menu

Explore Projects Groups Snippets