Skip to content

Commit dc89dcc

Browse files
added samples with tests
1 parent fa06a62 commit dc89dcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+12985
-12
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: TypeScript NestJS Server
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- samples/server/petstore/typescript-nestjs-server/**
7+
- .github/workflows/samples-typescript-nestjs-server.yaml
8+
jobs:
9+
build:
10+
name: Test TypeScript NestJS Server
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
sample:
16+
# clients
17+
- samples/server/petstore/typescript-nestjs-server
18+
node-version:
19+
- 16
20+
- 18
21+
- 20
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Install
30+
working-directory: ${{ matrix.sample }}
31+
run: |
32+
npm run preinstall
33+
npm i
34+
35+
- name: Test
36+
working-directory: ${{ matrix.sample }}
37+
run: npm run test

CI/circle_parallel.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ elif [ "$NODE_INDEX" = "3" ]; then
115115
(cd samples/client/petstore/javascript-flowtyped && mvn integration-test)
116116
(cd samples/client/petstore/javascript-es6 && mvn integration-test)
117117
(cd samples/client/petstore/javascript-promise-es6 && mvn integration-test)
118+
(cd samples/server/petstore/typescript-nestjs-server && mvn integration-test)
118119

119120
else
120121
echo "Running node $NODE_INDEX ..."
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
generatorName: typescript-nestjs-server
2+
outputDir: samples/server/petstore/typescript-nestjs-server
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/typescript-nestjs-server

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsServerCodegen.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public class TypeScriptNestjsServerCodegen extends AbstractTypeScriptClientCodeg
4343
private static String FILE_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9.-]*$";
4444

4545
public static final String NPM_REPOSITORY = "npmRepository";
46-
public static final String WITH_INTERFACES = "withInterfaces";
4746
public static final String TAGGED_UNIONS = "taggedUnions";
4847
public static final String NEST_VERSION = "nestVersion";
4948
public static final String API_SUFFIX = "apiSuffix";
@@ -96,9 +95,6 @@ public TypeScriptNestjsServerCodegen() {
9695

9796
this.cliOptions.add(new CliOption(NPM_REPOSITORY,
9897
"Use this property to set an url your private npmRepo in the package.json"));
99-
this.cliOptions.add(CliOption.newBoolean(WITH_INTERFACES,
100-
"Setting this property to true will generate interfaces next to the default class implementations.",
101-
false));
10298
this.cliOptions.add(CliOption.newBoolean(TAGGED_UNIONS,
10399
"Use discriminators to create tagged unions instead of extending interfaces.",
104100
this.taggedUnions));
@@ -197,13 +193,6 @@ public void processOpts() {
197193
}
198194
}
199195

200-
if (additionalProperties.containsKey(WITH_INTERFACES)) {
201-
boolean withInterfaces = Boolean.parseBoolean(additionalProperties.get(WITH_INTERFACES).toString());
202-
if (withInterfaces) {
203-
apiTemplateFiles.put("apiInterface.mustache", "Interface.ts");
204-
}
205-
}
206-
207196
if (additionalProperties.containsKey(TAGGED_UNIONS)) {
208197
taggedUnions = Boolean.parseBoolean(additionalProperties.get(TAGGED_UNIONS).toString());
209198
}
@@ -303,7 +292,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap operations, L
303292
operation.httpMethod = camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
304293

305294
List<CodegenParameter> params = operation.allParams;
306-
if (params != null && params.size() == 0) {
295+
if (params != null && params.isEmpty()) {
307296
operation.allParams = null;
308297
}
309298
List<CodegenResponse> responses = operation.responses;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
/build
5+
6+
# Logs
7+
logs
8+
*.log
9+
npm-debug.log*
10+
pnpm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# OS
16+
.DS_Store
17+
18+
# Tests
19+
/coverage
20+
/.nyc_output
21+
22+
# IDEs and editors
23+
/.idea
24+
.project
25+
.classpath
26+
.c9/
27+
*.launch
28+
.settings/
29+
*.sublime-workspace
30+
31+
# IDE - VSCode
32+
.vscode/*
33+
!.vscode/settings.json
34+
!.vscode/tasks.json
35+
!.vscode/launch.json
36+
!.vscode/extensions.json
37+
38+
# dotenv environment variable files
39+
.env
40+
.env.development.local
41+
.env.test.local
42+
.env.production.local
43+
.env.local
44+
45+
# temp directory
46+
.temp
47+
.tmp
48+
49+
# Runtime data
50+
pids
51+
*.pid
52+
*.seed
53+
*.pid.lock
54+
55+
# Diagnostic reports (https://nodejs.org/api/report.html)
56+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
pnpm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# OS
15+
.DS_Store
16+
17+
# Tests
18+
/coverage
19+
/.nyc_output
20+
21+
# IDEs and editors
22+
/.idea
23+
.project
24+
.classpath
25+
.c9/
26+
*.launch
27+
.settings/
28+
*.sublime-workspace
29+
30+
# IDE - VSCode
31+
.vscode/*
32+
!.vscode/settings.json
33+
!.vscode/tasks.json
34+
!.vscode/launch.json
35+
!.vscode/extensions.json
36+
37+
# dotenv environment variable files
38+
.env
39+
.env.development.local
40+
.env.test.local
41+
.env.production.local
42+
.env.local
43+
44+
# parcel-bundler cache (https://parceljs.org/)
45+
.cache
46+
.parcel-cache
47+
48+
# Next.js build output
49+
.next
50+
51+
# Nuxt.js build / generate output
52+
.nuxt
53+
dist
54+
55+
# Storybook build outputs
56+
.out
57+
.storybook-out
58+
59+
# Temporary folders
60+
tmp/
61+
temp/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.gitignore
2+
README.md
3+
api-implementations.ts
4+
api.module.ts
5+
api/PetApi.ts
6+
api/StoreApi.ts
7+
api/UserApi.ts
8+
api/index.ts
9+
controllers/PetApi.controller.ts
10+
controllers/StoreApi.controller.ts
11+
controllers/UserApi.controller.ts
12+
controllers/index.ts
13+
index.ts
14+
models/api-response.ts
15+
models/category.ts
16+
models/index.ts
17+
models/order.ts
18+
models/pet.ts
19+
models/tag.ts
20+
models/user.ts
21+
tsconfig.json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.15.0-SNAPSHOT

0 commit comments

Comments
 (0)