Skip to content

Commit 65703ff

Browse files
committed
change template files to remove jackson if disabled
1 parent 1b32f5e commit 65703ff

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/api.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import {{javaxPackage}}.validation.Valid;{{/useBeanValidation}}
2323
/**
2424
* Represents a collection of functions to interact with the API endpoints.
2525
*/
26-
@Path("{{commonPath}}"){{#useSwaggerAnnotations}}
26+
{{^interfaceOnly}}
27+
@Path("{{commonPath}}")
28+
{{/interfaceOnly}}
29+
{{#useSwaggerAnnotations}}
2730
@Api(description = "the {{{baseName}}} API"){{/useSwaggerAnnotations}}{{#hasConsumes}}
2831
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
2932
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @return {{{message}}}
99
{{/responses}}
1010
*/
11-
@{{httpMethod}}{{#subresourceOperation}}
12-
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
11+
@{{httpMethod}}
12+
@Path("{{commonPath}}{{{path}}}"){{#hasConsumes}}
1313
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
1414
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#useSwaggerAnnotations}}
1515
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}"{{#hasAuthMethods}}, authorizations = {

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
}
2121

2222
@Override
23+
{{#jackson}}
2324
@JsonValue
25+
{{/jackson}}
2426
public String toString() {
2527
return String.valueOf(value);
2628
}
@@ -40,6 +42,7 @@
4042
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected string value '" + s + "'");{{/isNullable}}
4143
}
4244

45+
{{#jackson}}
4346
@JsonCreator
4447
public static {{datatypeWithEnum}} fromValue({{dataType}} value) {
4548
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
@@ -49,4 +52,5 @@
4952
}
5053
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}}
5154
}
55+
{{/jackson}}
5256
}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumOuterClass.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ import com.fasterxml.jackson.annotation.JsonValue;
4141
}
4242

4343
@Override
44+
{{#jackson}}
4445
@JsonValue
46+
{{/jackson}}
4547
public String toString() {
4648
return String.valueOf(value);
4749
}
4850

51+
{{#jackson}}
4952
@JsonCreator
5053
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
5154
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
@@ -55,4 +58,5 @@ import com.fasterxml.jackson.annotation.JsonValue;
5558
}
5659
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}}
5760
}
61+
{{/jackson}}
5862
}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import io.swagger.annotations.*;
33
{{/useSwaggerAnnotations}}
44
import java.util.Objects;
5+
{{#jackson}}
56
import com.fasterxml.jackson.annotation.JsonProperty;
67
import com.fasterxml.jackson.annotation.JsonCreator;
78
import com.fasterxml.jackson.annotation.JsonValue;
89
import com.fasterxml.jackson.annotation.JsonTypeName;
9-
10+
{{/jackson}}
1011
{{#withXml}}
1112
import {{javaxPackage}}.xml.bind.annotation.XmlElement;
1213
import {{javaxPackage}}.xml.bind.annotation.XmlRootElement;
@@ -22,7 +23,7 @@ import {{javaxPackage}}.xml.bind.annotation.XmlEnumValue;
2223
**/{{/description}}
2324
{{#useSwaggerAnnotations}}{{#description}}@ApiModel(description = "{{{.}}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
2425
@org.eclipse.microprofile.openapi.annotations.media.Schema({{#title}}title="{{{.}}}", {{/title}}{{#description}}description="{{{.}}}"{{/description}}{{^description}}description=""{{/description}}){{/useMicroProfileOpenAPIAnnotations}}
25-
@JsonTypeName("{{name}}")
26+
{{#jackson}}@JsonTypeName("{{name}}"){{/jackson}}
2627
{{>generatedAnnotation}}{{>additionalModelTypeAnnotations}}{{>xmlPojoAnnotation}}
2728
{{#vendorExtensions.x-class-extra-annotation}}
2829
{{{vendorExtensions.x-class-extra-annotation}}}
@@ -61,6 +62,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
6162
public {{classname}}() {
6263
}
6364

65+
{{#jackson}}
6466
{{#generateJsonCreator}}
6567
{{#hasRequired}}
6668
@JsonCreator
@@ -85,6 +87,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
8587

8688
{{/hasRequired}}
8789
{{/generateJsonCreator}}
90+
{{/jackson}}
8891
{{#vars}}
8992
/**
9093
{{#description}}
@@ -108,12 +111,14 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
108111
{{#vendorExtensions.x-extra-annotation}}{{{vendorExtensions.x-extra-annotation}}}{{/vendorExtensions.x-extra-annotation}}{{#useSwaggerAnnotations}}
109112
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
110113
@org.eclipse.microprofile.openapi.annotations.media.Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useMicroProfileOpenAPIAnnotations}}
111-
@JsonProperty({{#required}}required = {{required}}, value = {{/required}}"{{baseName}}")
114+
{{#jackson}}@JsonProperty({{#required}}required = {{required}}, value = {{/required}}"{{baseName}}"){{/jackson}}
112115
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}public {{>beanValidatedType}} {{getter}}() {
113116
return {{name}};
114117
}
115118

119+
{{#jackson}}
116120
@JsonProperty({{#required}}required = {{required}}, value = {{/required}}"{{baseName}}")
121+
{{/jackson}}
117122
{{#vendorExtensions.x-setter-extra-annotation}}{{{vendorExtensions.x-setter-extra-annotation}}}
118123
{{/vendorExtensions.x-setter-extra-annotation}}public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
119124
this.{{name}} = {{name}};

0 commit comments

Comments
 (0)