@team-supercharge/oasg 13.0.0-test-export-01191261.0 → 13.1.0-master-ac68fc1d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +20 -12
  2. package/bin/oasg +11 -14
  3. package/config.schema.yml +3 -3
  4. package/package.json +2 -2
  5. package/targets/android/generate.sh +2 -2
  6. package/targets/android/generator-config.json +6 -1
  7. package/targets/android/templates/build.gradle.mustache +54 -21
  8. package/targets/android/templates/libraries/jvm-retrofit2/api.mustache +2 -10
  9. package/targets/android/templates/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache +354 -0
  10. package/targets/common.sh +0 -8
  11. package/targets/feign/generator-config.json +4 -3
  12. package/targets/feign/templates/beanValidation.mustache +2 -7
  13. package/targets/feign/templates/formParams.mustache +2 -1
  14. package/targets/feign/templates/libraries/spring-cloud/clientConfiguration.mustache +118 -0
  15. package/targets/feign/templates/libraries/spring-cloud/pom-sb3.mustache +16 -16
  16. package/targets/feign/templates/libraries/spring-cloud/pom.mustache +16 -16
  17. package/targets/feign-kotlin/generator-config.json +3 -3
  18. package/targets/feign-kotlin/templates/libraries/spring-cloud/pom-sb3.mustache +2 -1
  19. package/targets/flutter/generate.sh +0 -5
  20. package/targets/nestjs/generate.sh +1 -0
  21. package/targets/nestjs/generator-config.json +5 -0
  22. package/targets/nestjs/templates/api.service.mustache +1 -1
  23. package/targets/nestjs/templates/reorder-operations.js +1 -1
  24. package/targets/nestjs/templates/rewrite-path-parameters.js +2 -2
  25. package/targets/react/generator-config.json +24 -0
  26. package/targets/react/templates/apis.index.mustache +18 -0
  27. package/targets/react/templates/hook.mustache +111 -0
  28. package/targets/react/templates/package.mustache +45 -0
  29. package/targets/react/templates/tsconfig.esm.mustache +8 -0
  30. package/targets/react/templates/tsconfig.mustache +26 -0
  31. package/targets/react/templates/use-api.hook.mustache +155 -0
  32. package/targets/spring/generator-config.json +4 -4
  33. package/targets/spring/templates/libraries/spring-boot/pom-sb3.mustache +247 -0
  34. package/targets/spring/templates/libraries/spring-boot/pom.mustache +257 -0
  35. package/targets/spring-kotlin/generator-config.json +3 -3
  36. package/targets/spring-kotlin/templates/libraries/spring-boot/pom-sb3.mustache +0 -1
  37. package/targets/spring-kotlin/templates/libraries/spring-boot/pom.mustache +0 -1
  38. package/targets/.env +0 -3
  39. package/targets/feign-kotlin/templates/apiInterface.mustache +0 -108
  40. package/targets/feign-kotlin/templates/dataClassReqVar.mustache +0 -5
  41. package/targets/react-native/generator-config.json +0 -7
  42. package/targets/spring-kotlin/templates/dataClassReqVar.mustache +0 -5
  43. /package/targets/{react-native → react}/generate.sh +0 -0
  44. /package/targets/{react-native → react}/publish.sh +0 -0
package/README.md CHANGED
@@ -393,7 +393,7 @@ Glob patterns are supported.
393
393
 
394
394
  ### Overrides
395
395
 
396
- The following sections can be overrided: `info`, `externalDocs`, `license` and `contact`.
396
+ The following sections can be overridden: `info`, `externalDocs`, `license` and `contact`.
397
397
 
398
398
  It does not override but replace the values of the OpenApi Specification with the corresponding values of the `config.json`.
399
399
 
@@ -402,20 +402,20 @@ You can check [here](https://gitlab.supercharge.io/misc/oasg/-/blob/master/confi
402
402
  ```json
403
403
  "overrides": {
404
404
  "info": {
405
- "title": "Overrided Frontend API",
406
- "description": "Overrided Frontend Merged API Description",
407
- "termsOfService": "Overrided Terms Of Service",
405
+ "title": "Overridden Frontend API",
406
+ "description": "Overridden Frontend Merged API Description",
407
+ "termsOfService": "Overridden Terms Of Service",
408
408
  "version": "1.0.2"
409
409
  },
410
410
  "externalDocs": {
411
- "description": "Overrided externalDocs",
411
+ "description": "Overridden externalDocs",
412
412
  "url": "https://supercharge.io"
413
413
  },
414
414
  "license": {
415
- "name": "Overrided License"
415
+ "name": "Overridden License"
416
416
  },
417
417
  "contact": {
418
- "name": "Overrided Contact",
418
+ "name": "Overridden Contact",
419
419
  "url": "https://supercharge.io",
420
420
  "email": "hello@supercharge.io"
421
421
  }
@@ -454,12 +454,12 @@ Common target parameters
454
454
  | packageName | Name of the generated NPM package | Y | - |
455
455
  | repository | URL of the NPM package registry | Y | - |
456
456
 
457
- #### `react-native`
457
+ #### `react`
458
458
 
459
459
  ```json
460
460
  {
461
- "id": "client-react-native",
462
- "type": "react-native",
461
+ "id": "client-react",
462
+ "type": "react",
463
463
  "source": "source-merged",
464
464
  "packageName": "@project/oasg-example-react-native",
465
465
  "repository": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/npm/"
@@ -777,9 +777,11 @@ describe('Auth', function () {
777
777
 
778
778
  This section covers the breaking changes and their migrations across major version upgrades.
779
779
 
780
- ## From `12.x.x` to `13.0.0`
780
+ ## From `12.x.x` to `13.0.1`
781
781
 
782
- ### Schema naming updates in `angular`, `python`, `ios` targets
782
+ > Due to version `13.0.0` has been published before erroneously (then unpublished) to the NPM registry, this version of the artifact won't be available either as an NPM package or a Docker base image. Please use the `13.0.1` patch version instead.
783
+
784
+ ### Schema naming updates in `angular`, `python`, `android`,`ios`, `nestjs`, `react` targets
783
785
 
784
786
  With the update to [OpenAPI Generator 7.0.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.0.0) the same breaking changes appear as in other targets before:
785
787
 
@@ -795,6 +797,12 @@ and more:
795
797
 
796
798
  * the default `ngVersion` parameter is set to `16.0.0` if you wish to specify another version, use e.g `"generatorCustomArgs": "-p ngVersion=12"` in your `config.json`
797
799
 
800
+ ### Breaking in `react-native` target
801
+
802
+ * as both technologies used the same `typescript-fetch`-based generator, with this version the previous `react-native` target has been renamed to a more generic `react` name
803
+ - if at the future the best practices would change between the web-based _React_ and _React Native_ mobile projects, the `react-native` target will be reintroduced
804
+ * enum key with multiple segments will contain underscores e.g. the enum key generated from the `value_one` value was used to be `VALUEONE`, this will become `VALUE_ONE` after the update
805
+
798
806
  ## From `11.x.x` to `12.0.0`
799
807
 
800
808
  The following options from the `openapi` target type has been moved to the [Source](#source) configuration.
package/bin/oasg CHANGED
@@ -33,24 +33,24 @@ const PROXY_PORT = '9999';
33
33
 
34
34
  const DEFAULT_GENERATOR_MAPPING = {
35
35
  // client targets
36
- "android": { version: '6.6.0', generator: 'kotlin' },
37
- "angular": { version: '7.0.0', generator: 'typescript-angular' },
38
- "feign": { version: '6.6.0', generator: 'spring' },
39
- "feign-kotlin": { version: '6.6.0', generator: 'kotlin-spring' },
40
- "flutter": { version: '7.0.0', generator: 'dart-dio' },
36
+ "android": { version: '7.0.1', generator: 'kotlin' },
37
+ "angular": { version: '7.0.1', generator: 'typescript-angular' },
38
+ "feign": { version: '7.0.1', generator: 'spring' },
39
+ "feign-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
40
+ "flutter": { version: '7.0.1', generator: 'dart-dio' },
41
41
  "ios": { version: '7.0.1', generator: 'swift5' },
42
- "python": { version: '7.0.0', generator: 'python' },
43
- "react-native": { version: '4.3.1', generator: 'typescript-fetch' },
42
+ "python": { version: '7.0.1', generator: 'python' },
43
+ "react": { version: '7.0.1', generator: 'typescript-fetch' },
44
44
  // server targets
45
- "nestjs": { version: '5.4.0', generator: 'typescript-angular' },
46
- "spring": { version: '6.6.0', generator: 'spring' },
47
- "spring-kotlin": { version: '6.6.0', generator: 'kotlin-spring' },
45
+ "nestjs": { version: '7.0.1', generator: 'typescript-angular' },
46
+ "spring": { version: '7.0.1', generator: 'spring' },
47
+ "spring-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
48
48
  // misc targets
49
49
  "contract-testing": { version: '4.3.1', generator: 'typescript-node' },
50
50
  "openapi": { version: undefined, generator: undefined },
51
51
  "stubby": { version: '4.3.1', generator: 'stubby' },
52
52
  };
53
- const DEFAULT_KTLINT_VERSION = '0.39.0';
53
+ const DEFAULT_KTLINT_VERSION = '1.0.0';
54
54
  const BIN_FOLDER = 'out/.bin';
55
55
  const TMP_FOLDER = 'out/.tmp';
56
56
 
@@ -108,9 +108,6 @@ async function run() {
108
108
 
109
109
  // generate
110
110
  .command(['generate [target]', 'g'], 'generate packages', (yargs) => {
111
- console.log('----------------------------')
112
- console.log(JSON.stringify(process.env))
113
- console.log('----------------------------')
114
111
  yargs
115
112
  .positional('target', {
116
113
  describe: 'specify a target (optional)',
package/config.schema.yml CHANGED
@@ -11,7 +11,7 @@ properties:
11
11
  items:
12
12
  oneOf:
13
13
  - $ref: '#/targets/Angular'
14
- - $ref: '#/targets/ReactNative'
14
+ - $ref: '#/targets/React'
15
15
  - $ref: '#/targets/Feign'
16
16
  - $ref: '#/targets/FeignKotlin'
17
17
  - $ref: '#/targets/Spring'
@@ -121,12 +121,12 @@ targets:
121
121
  - packageName
122
122
  - repository
123
123
 
124
- ReactNative:
124
+ React:
125
125
  allOf:
126
126
  - $ref: '#/targets/Base'
127
127
  - properties:
128
128
  type:
129
- pattern: "^react-native$"
129
+ pattern: "^react$"
130
130
  packageName:
131
131
  type: string
132
132
  repository:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "13.0.0-test-export-01191261.0",
3
+ "version": "13.1.0-master-ac68fc1d.0",
4
4
  "description": "Node-based tool to lint OpenAPI documents and generate clients, servers and documentation from them",
5
5
  "author": "Supercharge",
6
6
  "license": "MIT",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@apidevtools/json-schema-ref-parser": "^10.1.0",
30
30
  "@apidevtools/swagger-parser": "^10.1.0",
31
- "@redocly/cli": "1.0.0-beta.126",
31
+ "@redocly/cli": "1.2.0",
32
32
  "@stoplight/prism-cli": "4.14.1",
33
33
  "@stoplight/spectral-cli": "6.6.0",
34
34
  "ajv": "^8.12.0",
@@ -7,7 +7,7 @@ mkdir -p out/$targetId
7
7
 
8
8
  if [ -z "$formatterCustomArgs" ]
9
9
  then
10
- formatterCustomArgs="--disabled_rules=no-wildcard-imports,max-line-length"
10
+ formatterCustomArgs="--disabled_rules=no-wildcard-imports,max-line-length,enum-entry-name-case"
11
11
  fi
12
12
 
13
13
  java -jar $binary generate \
@@ -18,4 +18,4 @@ java -jar $binary generate \
18
18
  -c $(dirname "$0")/generator-config.json \
19
19
  -p "artifactId=${artifactId},groupId=${groupId},packageName=${packageName},artifactVersion=${version}" $generatorCustomArgs
20
20
 
21
- $formatterBinary --verbose -F "out/$targetId/src/**/*.kt" $formatterCustomArgs --android
21
+ $formatterBinary -F "out/$targetId/src/**/*.kt" $formatterCustomArgs
@@ -4,5 +4,10 @@
4
4
  "dateLibrary": "java8-localdatetime",
5
5
  "useCoroutines": true,
6
6
  "moshiCodeGen": true,
7
- "omitGradleWrapper": true
7
+ "omitGradleWrapper": false,
8
+ "inlineSchemaOptions": {
9
+ "ARRAY_ITEM_SUFFIX": "",
10
+ "MAP_ITEM_SUFFIX": "",
11
+ "SKIP_SCHEMA_REUSE": "true"
12
+ }
8
13
  }
@@ -9,7 +9,7 @@ wrapper {
9
9
  {{/omitGradleWrapper}}
10
10
 
11
11
  buildscript {
12
- ext.kotlin_version = '1.7.21'
12
+ ext.kotlin_version = '1.8.10'
13
13
  {{#jvm-ktor}}
14
14
  ext.ktor_version = '2.1.3'
15
15
  {{/jvm-ktor}}
@@ -28,6 +28,16 @@ buildscript {
28
28
  {{#jvm-vertx}}
29
29
  ext.vertx_version = "4.3.3"
30
30
  {{/jvm-vertx}}
31
+ {{#jvm-spring-webclient}}
32
+ {{#useSpringBoot3}}
33
+ ext.spring_boot_version = "3.1.0"
34
+ {{/useSpringBoot3}}
35
+ {{^useSpringBoot3}}
36
+ ext.spring_boot_version = "2.7.12"
37
+ {{/useSpringBoot3}}
38
+ ext.reactor_version = "3.5.6"
39
+ {{/jvm-spring-webclient}}
40
+ ext.spotless_version = "6.13.0"
31
41
 
32
42
  repositories {
33
43
  maven { url "https://repo1.maven.org/maven2" }
@@ -37,6 +47,7 @@ buildscript {
37
47
  {{#kotlinx_serialization}}
38
48
  classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
39
49
  {{/kotlinx_serialization}}
50
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version"
40
51
  }
41
52
  }
42
53
 
@@ -54,6 +65,7 @@ apply plugin: 'kotlinx-serialization'
54
65
  apply plugin: 'idea'
55
66
  {{/idea}}
56
67
  apply plugin: 'maven-publish'
68
+ apply plugin: 'com.diffplug.spotless'
57
69
  {{^useSettingsGradle}}
58
70
 
59
71
  repositories {
@@ -61,6 +73,27 @@ repositories {
61
73
  }
62
74
  {{/useSettingsGradle}}
63
75
 
76
+ // Use spotless plugin to automatically format code, remove unused import, etc
77
+ // To apply changes directly to the file, run `gradlew spotlessApply`
78
+ // Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
79
+ spotless {
80
+ // comment out below to run spotless as part of the `check` task
81
+ enforceCheck false
82
+
83
+ format 'misc', {
84
+ // define the files (e.g. '*.gradle', '*.md') to apply `misc` to
85
+ target '.gitignore'
86
+
87
+ // define the steps to apply to those files
88
+ trimTrailingWhitespace()
89
+ indentWithSpaces() // Takes an integer argument if you don't like 4
90
+ endWithNewline()
91
+ }
92
+ kotlin {
93
+ ktfmt()
94
+ }
95
+ }
96
+
64
97
  test {
65
98
  useJUnitPlatform()
66
99
  }
@@ -73,7 +106,13 @@ idea {
73
106
  }
74
107
  }
75
108
  {{/idea}}
76
-
109
+ {{#jvm-spring-webclient}}{{#useSpringBoot3}}
110
+ kotlin {
111
+ jvmToolchain {
112
+ languageVersion.set(JavaLanguageVersion.of(17))
113
+ }
114
+ }
115
+ {{/useSpringBoot3}}{{/jvm-spring-webclient}}
77
116
  dependencies {
78
117
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
79
118
  {{^doNotUseRxAndCoroutines}}
@@ -84,13 +123,13 @@ dependencies {
84
123
  {{#moshi}}
85
124
  {{^moshiCodeGen}}
86
125
  implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
87
- implementation "com.squareup.moshi:moshi-kotlin:1.13.0"
88
- implementation "com.squareup.moshi:moshi-adapters:1.13.0"
126
+ implementation "com.squareup.moshi:moshi-kotlin:1.14.0"
127
+ implementation "com.squareup.moshi:moshi-adapters:1.14.0"
89
128
  {{/moshiCodeGen}}
90
129
  {{#moshiCodeGen}}
91
- implementation "com.squareup.moshi:moshi:1.13.0"
92
- implementation "com.squareup.moshi:moshi-adapters:1.13.0"
93
- kapt "com.squareup.moshi:moshi-kotlin-codegen:1.13.0"
130
+ implementation "com.squareup.moshi:moshi:1.14.0"
131
+ implementation "com.squareup.moshi:moshi-adapters:1.14.0"
132
+ kapt "com.squareup.moshi:moshi-kotlin-codegen:1.14.0"
94
133
  {{/moshiCodeGen}}
95
134
  {{/moshi}}
96
135
  {{#gson}}
@@ -98,8 +137,8 @@ dependencies {
98
137
  {{/gson}}
99
138
  {{#jackson}}
100
139
  implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
101
- implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.13.3"
102
- implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3"
140
+ implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3"
141
+ implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3"
103
142
  {{/jackson}}
104
143
  {{#kotlinx_serialization}}
105
144
  implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
@@ -120,10 +159,14 @@ dependencies {
120
159
  implementation "com.squareup.okhttp3:okhttp:3.12.13"
121
160
  {{/jvm-okhttp3}}
122
161
  {{#jvm-okhttp4}}
123
- implementation "com.squareup.okhttp3:okhttp:4.10.0"
162
+ implementation "com.squareup.okhttp3:okhttp:4.11.0"
124
163
  {{/jvm-okhttp4}}
164
+ {{#jvm-spring-webclient}}
165
+ implementation "org.springframework.boot:spring-boot-starter-webflux:$spring_boot_version"
166
+ implementation "io.projectreactor:reactor-core:$reactor_version"
167
+ {{/jvm-spring-webclient}}
125
168
  {{#threetenbp}}
126
- implementation "org.threeten:threetenbp:1.5.1"
169
+ implementation "org.threeten:threetenbp:1.6.8"
127
170
  {{/threetenbp}}
128
171
  {{#jvm-retrofit2}}
129
172
  {{#hasOAuthMethods}}
@@ -175,15 +218,12 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
175
218
  {{/kotlinx_serialization}}
176
219
 
177
220
  // OASg added for publication
178
-
179
221
  buildscript {
180
222
  dependencies {
181
223
  classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.7.20'
182
224
  }
183
225
  }
184
-
185
226
  apply plugin: 'org.jetbrains.dokka'
186
-
187
227
  task dokkaJar(type: Jar) {
188
228
  group = JavaBasePlugin.DOCUMENTATION_GROUP
189
229
  description = "Assembles Kotlin docs with Dokka"
@@ -191,38 +231,31 @@ task dokkaJar(type: Jar) {
191
231
  from(dokkaHtml)
192
232
  dependsOn(dokkaHtml)
193
233
  }
194
-
195
234
  task sourceJar(type: Jar) {
196
235
  archiveClassifier.set('sources')
197
236
  from sourceSets.main.allSource
198
237
  from 'build/generated/source/kapt/main'
199
238
  dependsOn project.tasks.getByName("compileKotlin")
200
239
  }
201
-
202
240
  publishing {
203
241
  publications {
204
242
  maven(MavenPublication) {
205
243
  groupId = '{{packageName}}'
206
244
  artifactId = '{{artifactId}}'
207
245
  version = "{{artifactVersion}}"
208
-
209
246
  artifact(dokkaJar)
210
247
  artifact(sourceJar)
211
-
212
248
  from components.java
213
249
  }
214
250
  }
215
-
216
251
  repositories {
217
252
  maven {
218
253
  name = "Gitlab"
219
254
  url = project.repoUrl
220
-
221
255
  credentials(HttpHeaderCredentials) {
222
256
  name = "Job-Token"
223
257
  value = System.env.CI_JOB_TOKEN
224
258
  }
225
-
226
259
  authentication {
227
260
  header(HttpHeaderAuthentication)
228
261
  }
@@ -65,12 +65,6 @@ import okhttp3.MultipartBody
65
65
 
66
66
  {{/isMultipart}}
67
67
  {{/x-kotlin-multipart-import}}
68
- {{#operation}}
69
- {{#isResponseFile}}
70
- import okhttp3.ResponseBody
71
-
72
- {{/isResponseFile}}
73
- {{/operation}}
74
68
  interface {{classname}} {
75
69
  {{#operation}}
76
70
  {{#allParams}}
@@ -79,7 +73,7 @@ interface {{classname}} {
79
73
  /**
80
74
  * enum for parameter {{paramName}}
81
75
  */
82
- {{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{enumName}}_{{operationId}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}) {
76
+ {{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{enumName}}{{operationIdCamelCase}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}) {
83
77
  {{^enumUnknownDefaultCase}}
84
78
  {{#allowableValues}}
85
79
  {{#enumVars}}
@@ -151,9 +145,7 @@ interface {{classname}} {
151
145
  {{^formParams}}
152
146
  {{#prioritizedContentTypes}}
153
147
  {{#-first}}
154
- @Headers({
155
- "Content-Type:{{{mediaType}}}"
156
- })
148
+ @Headers("Content-Type:{{{mediaType}}}")
157
149
  {{/-first}}
158
150
  {{/prioritizedContentTypes}}
159
151
  {{/formParams}}