Skip to content

Commit 9839fc2

Browse files
committed
Merge branch 'notNullJacksonAnnotation' of https://github.com/swagger-api/swagger-codegen-generators into notNullJacksonAnnotation
2 parents dcb5e05 + afde8e2 commit 9839fc2

File tree

11 files changed

+176
-14
lines changed

11 files changed

+176
-14
lines changed

src/main/java/io/swagger/codegen/v3/generators/java/MicronautCodegen.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class MicronautCodegen extends AbstractJavaCodegen implements BeanValidat
3535
private static final String BASE_PACKAGE = "basePackage";
3636
private static final String USE_TAGS = "useTags";
3737
private static final String IMPLICIT_HEADERS = "implicitHeaders";
38+
private static final String SKIP_SUPPORT_FILES = "skipSupportFiles";
3839

3940
private String title = "swagger-petstore";
4041
private String configPackage = "io.swagger.configuration";
@@ -66,6 +67,7 @@ private void init() {
6667
cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
6768
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
6869
cliOptions.add(new CliOption(BASE_PACKAGE, "base package (invokerPackage) for generated code"));
70+
cliOptions.add(new CliOption(SKIP_SUPPORT_FILES, "skip support files such as pom.xml, mvnw, etc from code generation."));
6971
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
7072
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
7173
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers."));
@@ -152,6 +154,11 @@ public void processOpts() {
152154
this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL));
153155
}
154156

157+
boolean skipSupportFiles = false;
158+
if (additionalProperties.containsKey(SKIP_SUPPORT_FILES)) {
159+
skipSupportFiles = Boolean.valueOf(additionalProperties.get(SKIP_SUPPORT_FILES).toString());
160+
}
161+
155162
if (useBeanValidation) {
156163
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
157164
}
@@ -164,14 +171,15 @@ public void processOpts() {
164171
writePropertyBack(USE_OPTIONAL, useOptional);
165172
}
166173

167-
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
168-
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
169-
supportingFiles.add(new SupportingFile("mvnw", "", "mvnw"));
170-
supportingFiles.add(new SupportingFile("mvnw.cmd", "", "mvnw.cmd"));
171-
supportingFiles.add(new SupportingFile("unsupportedOperationExceptionHandler.mustache",
174+
if (!skipSupportFiles) {
175+
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
176+
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
177+
supportingFiles.add(new SupportingFile("mvnw", "", "mvnw"));
178+
supportingFiles.add(new SupportingFile("mvnw.cmd", "", "mvnw.cmd"));
179+
supportingFiles.add(new SupportingFile("unsupportedOperationExceptionHandler.mustache",
172180
(sourceFolder + File.separator + configPackage).replace(".", File.separator), "UnsupportedOperationExceptionHandler.java"));
173-
supportingFiles.add(new SupportingFile("mainApplication.mustache", (sourceFolder + File.separator).replace(".", File.separator), "MainApplication.java"));
174-
181+
supportingFiles.add(new SupportingFile("mainApplication.mustache", (sourceFolder + File.separator).replace(".", File.separator), "MainApplication.java"));
182+
}
175183
addHandlebarsLambdas(additionalProperties);
176184
}
177185

src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptFetchClientCodegen.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.util.Date;
66

77
import io.swagger.codegen.v3.CliOption;
8+
import io.swagger.codegen.v3.CodegenConstants;
89
import io.swagger.codegen.v3.CodegenModel;
10+
import io.swagger.codegen.v3.CodegenParameter;
911
import io.swagger.codegen.v3.SupportingFile;
1012
import io.swagger.v3.oas.models.media.ArraySchema;
1113
import io.swagger.v3.oas.models.media.BinarySchema;
@@ -76,6 +78,7 @@ public void processOpts() {
7678

7779
supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts"));
7880
supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts"));
81+
supportingFiles.add(new SupportingFile("api_test.mustache", "", "api_test.spec.ts"));
7982
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
8083
supportingFiles.add(new SupportingFile("custom.d.mustache", "", "custom.d.ts"));
8184
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
@@ -143,6 +146,15 @@ private boolean isLanguageGenericType(String type) {
143146
return false;
144147
}
145148

149+
@Override
150+
public void postProcessParameter(CodegenParameter parameter) {
151+
super.postProcessParameter(parameter);
152+
153+
String type = applyLocalTypeMapping(parameter.dataType);
154+
parameter.dataType = type;
155+
parameter.getVendorExtensions().put(CodegenConstants.IS_PRIMITIVE_TYPE_EXT_NAME, isLanguagePrimitive(type));
156+
}
157+
146158
private void addNpmPackageGeneration() {
147159
if (additionalProperties.containsKey(NPM_NAME)) {
148160
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{>licenseInfo}}
2+
3+
import * as api from "./api"
4+
import { Configuration } from "./configuration"
5+
6+
const config: Configuration = {}
7+
8+
{{#apiInfo}}
9+
{{#apis}}
10+
{{#operations}}
11+
describe("{{classname}}", () => {
12+
let instance: api.{{classname}}
13+
beforeEach(function() {
14+
instance = new api.{{classname}}(config)
15+
});
16+
17+
{{#operation}}
18+
test("{{operationId}}", () => {
19+
{{#allParams}}
20+
const {{{paramName}}}: {{^isPrimitiveType}}api.{{/isPrimitiveType}}{{{dataType}}} = {{>api_test_default_value}}
21+
{{/allParams}}
22+
return expect(instance.{{operationId}}({{#allParams}}{{{paramName}}}, {{/allParams}}{})).resolves.toBe(null)
23+
})
24+
{{/operation}}
25+
})
26+
27+
{{/operations}}
28+
{{/apis}}
29+
{{/apiInfo}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#example}}{{#isString}}"{{{example}}}"{{/isString}}{{^isString}}{{#isUuid}}"{{{example}}}"{{/isUuid}}{{^isUuid}}{{{example}}}{{/isUuid}}{{/isString}}{{/example}}{{^example}}undefined{{/example}}

src/main/resources/handlebars/typescript-fetch/licenseInfo.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
66
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
77
*
8-
* NOTE: This class is auto generated by the swagger code generator program.
8+
* NOTE: This file is auto generated by the swagger code generator program.
99
* https://github.com/swagger-api/swagger-codegen.git
10-
* Do not edit the class manually.
10+
* Do not edit the file manually.
1111
*/

src/main/resources/handlebars/typescript-fetch/package.mustache

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,26 @@
1414
"typings": "./dist/index.d.ts",
1515
"scripts" : {
1616
"build": "tsc --outDir dist/",
17+
"test": "jest",
1718
"prepublishOnly": "npm run build"
1819
},
1920
"dependencies": {
2021
"portable-fetch": "^3.0.0"
2122
},
2223
"devDependencies": {
23-
"@types/node": "^8.0.9",
24-
"typescript": "^2.0"
25-
}{{#npmRepository}},{{/npmRepository}}
26-
{{#npmRepository}}
24+
"@types/jest": "^25.2.1",
25+
"@types/node": "^13.13.0",
26+
"jest": "^25.4.0",
27+
"ts-jest": "^25.4.0",
28+
"typescript": "^3.8.3"
29+
},
30+
"jest": {
31+
"transform": {
32+
"^.+\\.tsx?$": "ts-jest"
33+
},
34+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
35+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
36+
}{{#npmRepository}},
2737
"publishConfig":{
2838
"registry":"{{npmRepository}}"
2939
}

src/main/resources/handlebars/typescript-fetch/tsconfig.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"exclude": [
1616
"dist",
17-
"node_modules"
17+
"node_modules",
18+
"**/*.spec.ts"
1819
]
1920
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{>licenseInfo}}
2+
3+
import * as api from "./api"
4+
import { Configuration } from "./configuration"
5+
6+
const config: Configuration = {}
7+
8+
{{#apiInfo}}
9+
{{#apis}}
10+
{{#operations}}
11+
describe("{{classname}}", () => {
12+
let instance: api.{{classname}}
13+
beforeEach(function() {
14+
instance = new api.{{classname}}(config)
15+
});
16+
17+
{{#operation}}
18+
test("{{operationId}}", () => {
19+
{{#allParams}}
20+
const {{{paramName}}}: {{^isPrimitiveType}}api.{{/isPrimitiveType}}{{{dataType}}} = {{>api_test_default_value}}
21+
{{/allParams}}
22+
return expect(instance.{{operationId}}({{#allParams}}{{{paramName}}}, {{/allParams}}{})).resolves.toBe(null)
23+
})
24+
{{/operation}}
25+
})
26+
27+
{{/operations}}
28+
{{/apis}}
29+
{{/apiInfo}}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* {{{appName}}}
3+
* {{{appDescription}}}
4+
*
5+
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
6+
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
7+
*
8+
* NOTE: This file is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the file manually.
11+
*/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "{{npmName}}",
3+
"version": "{{npmVersion}}",
4+
"description": "swagger client for {{npmName}}",
5+
"author": "Swagger Codegen Contributors",
6+
"keywords": [
7+
"fetch",
8+
"typescript",
9+
"swagger-client",
10+
"{{npmName}}"
11+
],
12+
"license": "Unlicense",
13+
"main": "./dist/index.js",
14+
"typings": "./dist/index.d.ts",
15+
"scripts" : {
16+
"build": "tsc --outDir dist/",
17+
"test": "jest",
18+
"prepublishOnly": "npm run build"
19+
},
20+
"dependencies": {
21+
"portable-fetch": "^3.0.0"
22+
},
23+
"devDependencies": {
24+
"@types/jest": "^25.2.1",
25+
"@types/node": "^13.13.0",
26+
"jest": "^25.4.0",
27+
"ts-jest": "^25.4.0",
28+
"typescript": "^3.8.3"
29+
},
30+
"jest": {
31+
"transform": {
32+
"^.+\\.tsx?$": "ts-jest"
33+
},
34+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
35+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
36+
}{{#npmRepository}},
37+
"publishConfig":{
38+
"registry":"{{npmRepository}}"
39+
}
40+
{{/npmRepository}}
41+
}

0 commit comments

Comments
 (0)