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
  • !10013

[JavaJaxrsResteasy] make it possible to disable generation of swagger annotations

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/b-com/feat/JavaJaxrsResteasy_Make_it_possible_to_disable_generation_of_swagger_annotations into master 4 years ago
  • Overview 0
  • Commits 23
  • Pipelines 1
  • Changes 9

Created by: tnmtechnologies

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.x, 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. @nmuesch
Compare
  • version 1
    07d5a78e
    2 years ago

  • master (base)

and
  • latest version
    07d5a78e
    23 commits, 2 years ago

  • version 1
    07d5a78e
    23 commits, 2 years ago

9 files
+ 44
- 28

    Preferences

    File browser
    Compare changes
docs/ge‎nerators‎
jaxrs-re‎steasy.md‎ +1 -0
mod‎ules‎
openapi-generator‎-gradle-plugin/…/…‎
gradle.p‎roperties‎ +1 -1
openapi-generator-m‎aven-plugin/examples‎
kotli‎n.xml‎ +1 -1
sprin‎g.xml‎ +1 -1
openapi-gener‎ator/src/main‎
java/org/openapitoo‎ls/codegen/languages‎
JavaResteasySer‎verCodegen.java‎ +31 -16
resources/Java‎JaxRS/resteasy‎
api.mu‎stache‎ +6 -6
bodyParam‎s.mustache‎ +1 -1
formParam‎s.mustache‎ +1 -1
headerPara‎ms.mustache‎ +1 -1
docs/generators/jaxrs-resteasy.md
+ 1
- 0
  • View file @ 07d5a78e

  • Edit in single-file editor

  • Open in Web IDE


Conflict: This file was modified in both the source and target branches. Ask someone with write access to resolve it.
@@ -52,6 +52,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src/main/java|
|swaggerAnnotations|Whether to generate Swagger annotations.| |true|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
|useTags|use tags for creating interface and controller classnames| |false|
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaResteasyServerCodegen.java
+ 31
- 16
  • View file @ 07d5a78e

  • Edit in single-file editor

  • Open in Web IDE


Conflict: This file was modified in both the source and target branches. Ask someone with write access to resolve it.
@@ -17,20 +17,28 @@
package org.openapitools.codegen.languages;
import org.apache.commons.lang3.BooleanUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.JbossFeature;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.BooleanUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.JbossFeature;
import org.openapitools.codegen.meta.features.DocumentationFeature;
public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature {
protected boolean generateJbossDeploymentDescriptor = true;
private static final String SWAGGER_ANNOTATIONS = "swaggerAnnotations";
private boolean swaggerAnnotations = true;
public JavaResteasyServerCodegen() {
super();
@@ -56,6 +64,7 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
cliOptions.add(
CliOption.newBoolean(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR, "Generate Jboss Deployment Descriptor"));
cliOptions.add(CliOption.newBoolean(SWAGGER_ANNOTATIONS, "Whether to generate Swagger annotations.", swaggerAnnotations));
}
@Override
@@ -73,11 +82,16 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
super.processOpts();
if (additionalProperties.containsKey(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR)) {
boolean generateJbossDeploymentDescriptorProp = convertPropertyToBooleanAndWriteBack(
final boolean generateJbossDeploymentDescriptorProp = convertPropertyToBooleanAndWriteBack(
GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR);
this.setGenerateJbossDeploymentDescriptor(generateJbossDeploymentDescriptorProp);
}
if (additionalProperties.containsKey(SWAGGER_ANNOTATIONS)) {
swaggerAnnotations = Boolean.parseBoolean(additionalProperties.get(SWAGGER_ANNOTATIONS).toString());
}
writePropertyBack(SWAGGER_ANNOTATIONS, swaggerAnnotations);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("gradle.mustache", "", "build.gradle")
@@ -129,12 +143,12 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
public Map<String, Object> postProcessOperationsWithModels(final Map<String, Object> objs, final List<Object> allModels) {
return super.postProcessOperationsWithModels(objs, allModels);
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
public void postProcessModelProperty(final CodegenModel model, final CodegenProperty property) {
super.postProcessModelProperty(model, property);
//Add imports for Jackson
if (!BooleanUtils.toBoolean(model.isEnum)) {
@@ -151,15 +165,15 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
objs = super.postProcessModelsEnum(objs);
//Add imports for Jackson
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
final List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
final List<Object> models = (List<Object>) objs.get("models");
for (final Object _mo : models) {
final Map<String, Object> mo = (Map<String, Object>) _mo;
final CodegenModel cm = (CodegenModel) mo.get("model");
// for enum model
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
if (Boolean.TRUE.equals(cm.isEnum) && (cm.allowableValues != null)) {
cm.imports.add(importMapping.get("JsonValue"));
Map<String, String> item = new HashMap<String, String>();
final Map<String, String> item = new HashMap<>();
item.put("import", importMapping.get("JsonValue"));
imports.add(item);
}
@@ -168,7 +182,8 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
return objs;
}
public void setGenerateJbossDeploymentDescriptor(boolean generateJbossDeploymentDescriptor) {
@Override
public void setGenerateJbossDeploymentDescriptor(final boolean generateJbossDeploymentDescriptor) {
this.generateJbossDeploymentDescriptor = generateJbossDeploymentDescriptor;
}
}
modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/api.mustache
+ 6
- 6
  • View file @ 07d5a78e

  • Edit in single-file editor

  • Open in Web IDE


Conflict: This file was modified in both the source and target branches. Ask someone with write access to resolve it.
@@ -3,8 +3,8 @@ package {{package}};
import {{modelPackage}}.*;
import {{package}}.{{classname}}Service;
import io.swagger.annotations.ApiParam;
import io.swagger.jaxrs.*;
{{#swaggerAnnotations}}import io.swagger.annotations.ApiParam;
import io.swagger.jaxrs.*;{{/swaggerAnnotations}}
{{#imports}}import {{import}};
{{/imports}}
@@ -29,8 +29,8 @@ import javax.validation.Valid;
{{/isMultipart}}{{/operation}}{{/operations}}
@Path("{{commonPath}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#swaggerAnnotations}}
@io.swagger.annotations.Api(description = "the {{{baseName}}} API"){{/swaggerAnnotations}}
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}} {
@@ -41,7 +41,7 @@ public class {{classname}} {
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#swaggerAnnotations}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnBaseType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#authMethods}}@io.swagger.annotations.Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
{{#scopes}}@io.swagger.annotations.AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}},
@@ -51,7 +51,7 @@ public class {{classname}} {
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} })
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{^-last}},
{{/-last}}{{/responses}} })
{{/-last}}{{/responses}} }){{/swaggerAnnotations}}
public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{^isMultipart}}{{>formParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}@Context SecurityContext securityContext)
throws NotFoundException {
return service.{{nickname}}({{#isMultipart}}input,{{/isMultipart}}{{#allParams}}{{^isMultipart}}{{paramName}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{paramName}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}securityContext);
modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/bodyParams.mustache
+ 1
- 1
  • View file @ 07d5a78e

  • Edit in single-file editor

  • Open in Web IDE

Conflict: This file was modified in both the source and target branches. Ask someone with write access to resolve it.
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#useBeanValidation}}{{#required}} @NotNull{{/required}} @Valid{{/useBeanValidation}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
{{#isBodyParam}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/swaggerAnnotations}}{{#useBeanValidation}}{{#required}} @NotNull{{/required}} @Valid{{/useBeanValidation}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/formParams.mustache
+ 1
- 1
  • View file @ 07d5a78e

  • Edit in single-file editor

  • Open in Web IDE

Conflict: This file was modified in both the source and target branches. Ask someone with write access to resolve it.
{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
{{#isFormParam}}{{^isFile}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/swaggerAnnotations}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{/isFormParam}}
\ No newline at end of file
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
2
2 participants
Administrator
Jim Schubert
Reference: OpenAPITools/openapi-generator!10013
Source branch: github/fork/b-com/feat/JavaJaxrsResteasy_Make_it_possible_to_disable_generation_of_swagger_annotations

Menu

Explore Projects Groups Snippets