@team-supercharge/oasg 19.0.0 → 20.0.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.
package/README.md CHANGED
@@ -231,6 +231,30 @@ This command is offered for `npm` based projects only to ensure that a working `
231
231
  $ npx oasg save-lock [target]
232
232
  ```
233
233
 
234
+ ## Dependency install cooldown
235
+
236
+ `npm install` only resolves package versions that have been on the registry for at least 7 days, so a
237
+ compromised release has a week to be caught and unpublished before it can reach a build. This is the
238
+ `NPM_CONFIG_MIN_RELEASE_AGE` npm setting, and it applies in two places:
239
+
240
+ * the _OASg_ image sets it for its own dependencies and CLI installs
241
+ * the target scripts set it for the installs the `npm` based targets (`angular`, `nestjs`, `msw`,
242
+ `react`, `contract-testing`, `typescript-axios`, `typescript-fetch`) perform while building the
243
+ generated SDK, so the cooldown holds even when _OASg_ runs outside its own image
244
+
245
+ `npm ci` is unaffected by design: it installs exactly what the lock file pins, which is what
246
+ [`save-lock`](#save-lock) is for.
247
+
248
+ If a target has to pick up a fresher release (a framework version published within the cooldown, for
249
+ example), override the variable on the job:
250
+
251
+ ```yaml
252
+ generate-sdk:
253
+ extends: .oasg
254
+ variables:
255
+ NPM_CONFIG_MIN_RELEASE_AGE: "0"
256
+ ```
257
+
234
258
  ---
235
259
 
236
260
  # Linter Rules
@@ -1195,6 +1219,26 @@ Validations from OpenAPI spec:
1195
1219
  | apiKey | Api key of nuget source (If not specified, provide the CI_JOB_TOKEN) | N | - |
1196
1220
  | generatorCustomArgs | Custom arguments of the generator (--global-property, --additional-properties) | N | - |
1197
1221
 
1222
+ > **Nullable object/enum references.** A property spec'd nullable as a
1223
+ > reference to a named schema — `nullable: true` alongside a `$ref` (OpenAPI
1224
+ > 3.0, typically via an `allOf` wrapper) or `oneOf: [$ref, {type: 'null'}]`
1225
+ > (OpenAPI 3.1) — now generates a nullable C# type (`Category?`), matching the
1226
+ > TypeScript targets' `Category | null`, regardless of whether the property is
1227
+ > `required`: `required` only governs presence of the key, never nullness of
1228
+ > the value. Previously only *optional, non-nullable* references got a `?`;
1229
+ > nullable references (required or not) silently generated a non-nullable
1230
+ > type, forcing consumers to suppress with `null!` and losing the compiler's
1231
+ > null-reference warnings at the point of use.
1232
+ >
1233
+ > Nullable **containers** (arrays, maps) are unaffected by this change and
1234
+ > still generate a non-nullable collection type.
1235
+ >
1236
+ > This applies to the `dotnet`, `dotnet-webapi` and
1237
+ > `dotnet-webapi-system-text-json` targets. `dotnet-system-text-json`
1238
+ > (`generichost`) already handled this correctly. To opt out entirely, disable
1239
+ > nullable reference types via `generatorCustomArgs`:
1240
+ > `--additional-properties=nullableReferenceTypes=false`.
1241
+
1198
1242
  #### `dotnet-system-text-json`
1199
1243
 
1200
1244
  An AOT-oriented C# **client library**. Unlike `dotnet` (which uses the
@@ -1519,6 +1563,37 @@ setupWorker(
1519
1563
 
1520
1564
  This section covers the breaking changes and their migrations across major version upgrades.
1521
1565
 
1566
+ ## From `19.x.x` to `20.0.0`
1567
+
1568
+ From this version _OASg_ requires `node` version `>=24.21` (the current LTS line) and `npm` version
1569
+ `>=11` by default. `node@20` reached its end of life, so please upgrade your projects accordingly.
1570
+
1571
+ The `stubby` target's generated `Dockerfile` is based on `node:24.21.0-alpine` as well.
1572
+
1573
+ A 7 day [dependency install cooldown](#dependency-install-cooldown) now applies to every
1574
+ `npm install` _OASg_ runs, including the ones the `npm` based targets perform while building the
1575
+ generated SDK. A target that must pick up a release younger than that needs
1576
+ `NPM_CONFIG_MIN_RELEASE_AGE: "0"` on its job.
1577
+
1578
+ ### Peer dependencies in the `npm` based targets
1579
+
1580
+ Framework packages that belong to the consuming application are declared as `peerDependencies`
1581
+ instead of being pinned by the generated SDK, so the application decides which version is used:
1582
+
1583
+ * `typescript-axios`: `axios` moved from `dependencies` to `peerDependencies` (`^1.6.1`).
1584
+ Applications that relied on the SDK to pull `axios` in have to depend on it themselves.
1585
+ * `angular`: `@angular/common` is declared as a peer next to `@angular/core` and `rxjs`, as the
1586
+ generated services import `HttpClient` from `@angular/common/http`.
1587
+ * `nestjs`: `reflect-metadata` is `^0.2.2` rather than the exact `0.2.2`, `@types/multer` became an
1588
+ optional peer (it is only needed for `binary` payloads), and the pinned `@types/validator` is no
1589
+ longer shipped as a runtime dependency, since `class-validator` already depends on it.
1590
+ * `react`: `@tanstack/react-query` is `^5.90.21` rather than the exact `5.90.21`, so any _React
1591
+ Query_ `5.x` can be used. The generated hooks take `NoInfer` from TypeScript instead of from
1592
+ `@tanstack/react-query`, which stopped re-exporting it in `5.10x`, so they need TypeScript `>=5.4`.
1593
+
1594
+ The `msw` target already declared `msw` as a peer, and `typescript-fetch` has no runtime dependency
1595
+ at all, so neither of them changed.
1596
+
1522
1597
  ## From `18.x.x` to `19.0.0`
1523
1598
 
1524
1599
  ### Breaking in `spring`, `spring-kotlin`, `feign` and `feign-kotlin` targets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "19.0.0",
3
+ "version": "20.0.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",
@@ -15,8 +15,8 @@
15
15
  "url": "git@gitlab.com:team-supercharge/oasg.git"
16
16
  },
17
17
  "engines": {
18
- "node": ">=20.19",
19
- "npm": ">=10"
18
+ "node": ">=24.21",
19
+ "npm": ">=11"
20
20
  },
21
21
  "files": [
22
22
  "bin",
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "{{{npmName}}}",
3
+ "version": "{{{npmVersion}}}",
4
+ "description": "OpenAPI client for {{{npmName}}}",
5
+ "author": "OpenAPI-Generator Contributors",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git"
9
+ },
10
+ "keywords": [
11
+ "openapi-client",
12
+ "openapi-generator"
13
+ ],
14
+ "license": "{{licenseName}}",
15
+ "scripts": {
16
+ "build": "ng-packagr -p ng-package.json"
17
+ },
18
+ "peerDependencies": {
19
+ "@angular/common": "^{{ngVersion}}",
20
+ "@angular/core": "^{{ngVersion}}",
21
+ "rxjs": "^{{rxjsVersion}}"
22
+ },
23
+ "devDependencies": {
24
+ "@angular/common": "^{{ngVersion}}",
25
+ "@angular/compiler": "^{{ngVersion}}",
26
+ "@angular/compiler-cli": "^{{ngVersion}}",
27
+ "@angular/core": "^{{ngVersion}}",
28
+ "@angular/platform-browser": "^{{ngVersion}}",
29
+ "ng-packagr": "^{{ngPackagrVersion}}",
30
+ "reflect-metadata": "^0.1.3",
31
+ "rxjs": "^{{rxjsVersion}}",{{#tsickleVersion}}
32
+ "tsickle": "^{{tsickleVersion}}",{{/tsickleVersion}}
33
+ "typescript": "{{{tsVersion}}}",
34
+ "zone.js": "^{{zonejsVersion}}"
35
+ }{{#npmRepository}},
36
+ "publishConfig": {
37
+ "registry": "{{{npmRepository}}}"
38
+ }
39
+ {{/npmRepository}}
40
+ }
package/targets/common.sh CHANGED
@@ -32,4 +32,12 @@ params=$(jq -r ".targets[] | select(.id == \"$targetId\") | del($blacklist) | to
32
32
  echo "$params"
33
33
  eval $params
34
34
 
35
+ # Only resolve package versions that have been on the registry for at least a week, so a compromised
36
+ # release has time to be caught and unpublished before it lands in a generated SDK. Every target's
37
+ # `npm install` inherits this, including when OASg runs outside its own image, where the image level
38
+ # default does not apply. Set NPM_CONFIG_MIN_RELEASE_AGE=0 on the job to turn the cooldown off.
39
+ : "${NPM_CONFIG_MIN_RELEASE_AGE:=7}"
40
+ export NPM_CONFIG_MIN_RELEASE_AGE
41
+ echo "npm install cooldown (NPM_CONFIG_MIN_RELEASE_AGE): $NPM_CONFIG_MIN_RELEASE_AGE day(s)"
42
+
35
43
  echo -e "=====\n"
@@ -0,0 +1,165 @@
1
+ {{>partial_header}}
2
+ using System;
3
+ using System.Linq;
4
+ using System.Text;
5
+ using System.Collections.Generic;
6
+ using System.ComponentModel;
7
+ using System.ComponentModel.DataAnnotations;
8
+ using System.Runtime.Serialization;
9
+ using Newtonsoft.Json;
10
+ using {{packageName}}.Converters;
11
+ {{#models}}
12
+ {{#model}}
13
+ {{/model}}
14
+ {{/models}}
15
+
16
+ {{#models}}
17
+ {{#model}}
18
+ namespace {{modelPackage}}
19
+ { {{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
20
+ /// <summary>
21
+ /// {{description}}
22
+ /// </summary>
23
+ [DataContract]
24
+ public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>
25
+ {
26
+ {{#vars}}
27
+ {{#items.isEnum}}
28
+ {{#items}}
29
+ {{^complexType}}
30
+ {{>enumClass}}
31
+ {{/complexType}}
32
+ {{/items}}
33
+ {{/items.isEnum}}
34
+ {{^items.isEnum}}
35
+ {{#isEnum}}
36
+ {{^complexType}}
37
+ {{>enumClass}}
38
+ {{/complexType}}
39
+ {{/isEnum}}
40
+ {{/items.isEnum}}
41
+ /// <summary>
42
+ /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
43
+ /// </summary>{{#description}}
44
+ /// <value>{{.}}</value>{{/description}}{{#required}}
45
+ [Required]{{/required}}{{#pattern}}
46
+ [RegularExpression("{{{.}}}")]{{/pattern}}{{#minLength}}{{#maxLength}}
47
+ [StringLength({{maxLength}}, MinimumLength={{minLength}})]{{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}}
48
+ [MinLength({{minLength}})]{{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}}
49
+ [MaxLength({{.}})]{{/maxLength}}{{/minLength}}{{#minimum}}{{#maximum}}
50
+ [Range({{minimum}}, {{maximum}})]{{/maximum}}{{/minimum}}
51
+ [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]
52
+ {{#isEnum}}
53
+ public {{{datatypeWithEnum}}}{{#isNullable}}?{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
54
+ {{/isEnum}}
55
+ {{^isEnum}}
56
+ {{! this generator never appends a question mark to dataType for a nullable object/model
57
+ ref (only for primitives in its hardcoded nullable-type list), so the isModel-guarded
58
+ branch below adds it back. isModel is never set for a primitive, so this cannot
59
+ produce a double question mark. Nullable containers are intentionally left non-null
60
+ (out of scope), matching the other .NET targets in this repo. }}
61
+ public {{{dataType}}}{{#nullableReferenceTypes}}{{#isNullable}}{{#isModel}}?{{/isModel}}{{/isNullable}}{{/nullableReferenceTypes}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
62
+ {{/isEnum}}
63
+ {{^-last}}
64
+
65
+ {{/-last}}
66
+ {{/vars}}
67
+
68
+ /// <summary>
69
+ /// Returns the string presentation of the object
70
+ /// </summary>
71
+ /// <returns>String presentation of the object</returns>
72
+ public override string ToString()
73
+ {
74
+ var sb = new StringBuilder();
75
+ sb.Append("class {{classname}} {\n");
76
+ {{#vars}}
77
+ sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
78
+ {{/vars}}
79
+ sb.Append("}\n");
80
+ return sb.ToString();
81
+ }
82
+
83
+ /// <summary>
84
+ /// Returns the JSON string presentation of the object
85
+ /// </summary>
86
+ /// <returns>JSON string presentation of the object</returns>
87
+ public {{#parent}}{{^isMap}}{{^isArray}}new {{/isArray}}{{/isMap}}{{/parent}}string ToJson()
88
+ {
89
+ return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
90
+ }
91
+
92
+ /// <summary>
93
+ /// Returns true if objects are equal
94
+ /// </summary>
95
+ /// <param name="obj">Object to be compared</param>
96
+ /// <returns>Boolean</returns>
97
+ public override bool Equals(object obj)
98
+ {
99
+ if (obj is null) return false;
100
+ if (ReferenceEquals(this, obj)) return true;
101
+ return obj.GetType() == GetType() && Equals(({{classname}})obj);
102
+ }
103
+
104
+ /// <summary>
105
+ /// Returns true if {{classname}} instances are equal
106
+ /// </summary>
107
+ /// <param name="other">Instance of {{classname}} to be compared</param>
108
+ /// <returns>Boolean</returns>
109
+ public bool Equals({{classname}} other)
110
+ {
111
+ if (other is null) return false;
112
+ if (ReferenceEquals(this, other)) return true;
113
+
114
+ return {{#vars}}{{^isContainer}}
115
+ (
116
+ {{name}} == other.{{name}} ||
117
+ {{^vendorExtensions.x-is-value-type}}{{name}} != null &&{{/vendorExtensions.x-is-value-type}}
118
+ {{name}}.Equals(other.{{name}})
119
+ ){{^-last}} && {{/-last}}{{/isContainer}}{{#isContainer}}
120
+ (
121
+ {{name}} == other.{{name}} ||
122
+ {{^vendorExtensions.x-is-value-type}}{{name}} != null &&
123
+ other.{{name}} != null &&
124
+ {{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(other.{{name}})
125
+ ){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
126
+ }
127
+
128
+ /// <summary>
129
+ /// Gets the hash code
130
+ /// </summary>
131
+ /// <returns>Hash code</returns>
132
+ public override int GetHashCode()
133
+ {
134
+ unchecked // Overflow is fine, just wrap
135
+ {
136
+ var hashCode = 41;
137
+ // Suitable nullity checks etc, of course :)
138
+ {{#vars}}
139
+ {{^vendorExtensions.x-is-value-type}}if ({{name}} != null){{/vendorExtensions.x-is-value-type}}
140
+ hashCode = hashCode * 59 + {{name}}.GetHashCode();
141
+ {{/vars}}
142
+ return hashCode;
143
+ }
144
+ }
145
+
146
+ #region Operators
147
+ #pragma warning disable 1591
148
+
149
+ public static bool operator ==({{classname}} left, {{classname}} right)
150
+ {
151
+ return Equals(left, right);
152
+ }
153
+
154
+ public static bool operator !=({{classname}} left, {{classname}} right)
155
+ {
156
+ return !Equals(left, right);
157
+ }
158
+
159
+ #pragma warning restore 1591
160
+ #endregion Operators
161
+ }
162
+ {{/isEnum}}
163
+ {{/model}}
164
+ {{/models}}
165
+ }
@@ -79,7 +79,12 @@ namespace {{modelPackage}}
79
79
  public {{{datatypeWithEnum}}}{{#isNullable}}{{^required}}?{{/required}}{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
80
80
  {{/isEnum}}
81
81
  {{^isEnum}}
82
- public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
82
+ {{! nullable object/model refs get no question mark from the generator's dataType, unlike
83
+ primitives whose dataType already carries one -- so the isModel-guarded branch below
84
+ adds it back for those. isModel is only set for refs to named schemas, never for a
85
+ primitive whose dataType is already nullable, so this cannot produce a double question
86
+ mark. Nullable containers are intentionally left non-nullable (out of scope). }}
87
+ public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{#isNullable}}{{#isModel}}?{{/isModel}}{{/isNullable}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
83
88
  {{/isEnum}}
84
89
  {{^-last}}
85
90
 
@@ -79,7 +79,12 @@ namespace {{modelPackage}}
79
79
  public {{{datatypeWithEnum}}}{{#isNullable}}{{^required}}?{{/required}}{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
80
80
  {{/isEnum}}
81
81
  {{^isEnum}}
82
- public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
82
+ {{! nullable object/model refs get no question mark from the generator's dataType, unlike
83
+ primitives whose dataType already carries one -- so the isModel-guarded branch below
84
+ adds it back for those. isModel is only set for refs to named schemas, never for a
85
+ primitive whose dataType is already nullable, so this cannot produce a double question
86
+ mark. Nullable containers are intentionally left non-nullable (out of scope). }}
87
+ public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{#isNullable}}{{#isModel}}?{{/isModel}}{{/isNullable}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
83
88
  {{/isEnum}}
84
89
  {{^-last}}
85
90
 
@@ -16,16 +16,20 @@
16
16
  "@nestjs/common": ">=10.0.0 <12.0.0",
17
17
  "@nestjs/core": ">=10.0.0 <12.0.0",
18
18
  "@nestjs/platform-express": ">=10.0.0 <12.0.0",
19
+ "@types/multer": "^1.4.7",
19
20
  "class-transformer": "^0.5.1",
20
21
  "class-validator": "^0.14.0",
21
- "reflect-metadata": "0.2.2",
22
+ "reflect-metadata": "^0.2.2",
22
23
  "rxjs": "^7.2.0"
23
24
  },
24
- "dependencies": {
25
- "@types/validator": "13.11.7"
25
+ "peerDependenciesMeta": {
26
+ "@types/multer": {
27
+ "optional": true
28
+ }
26
29
  },
27
30
  "devDependencies": {
28
31
  "@types/multer": "^1.4.7",
32
+ "@types/validator": "^13.11.7",
29
33
  "typescript": "^5",
30
34
  "@types/node": "^20"
31
35
  }{{#npmRepository}},
@@ -14,7 +14,6 @@ import {
14
14
  type DefinedInitialDataOptions,
15
15
  type UndefinedInitialDataOptions,
16
16
  type DefinedUseQueryResult,
17
- type NoInfer,
18
17
  type UseSuspenseQueryOptions,
19
18
  type UseSuspenseQueryResult,
20
19
  } from '@tanstack/react-query';
@@ -28,12 +28,12 @@
28
28
  "redux-ts-simple": "^3.2.0",
29
29
  "reselect": "^4.0.0",
30
30
  {{/sagasAndRecords}}
31
- "typescript": "^4.0",
31
+ "typescript": "^5.4",
32
32
  "@types/react": "^18.2.24 || ^19.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.2.0 || ^19.0.0",
36
- "@tanstack/react-query": "5.90.21"
36
+ "@tanstack/react-query": "^5.90.21"
37
37
  }{{#npmRepository}},{{/npmRepository}}
38
38
  {{#npmRepository}}
39
39
  "publishConfig": {
@@ -1,4 +1,4 @@
1
- FROM node:18.15-alpine
1
+ FROM node:24.21.0-alpine
2
2
 
3
3
  RUN npm install -g stubby
4
4
 
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "{{npmName}}",
3
+ "version": "{{npmVersion}}",
4
+ "description": "OpenAPI client for {{npmName}}",
5
+ "author": "OpenAPI-Generator Contributors",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git"
9
+ },
10
+ "keywords": [
11
+ "axios",
12
+ "typescript",
13
+ "openapi-client",
14
+ "openapi-generator",
15
+ "{{npmName}}"
16
+ ],
17
+ "license": "{{licenseName}}",
18
+ "main": "./dist/index.js",
19
+ "typings": "./dist/index.d.ts",
20
+ {{#supportsES6}}
21
+ "module": "./dist/esm/index.js",
22
+ "sideEffects": false,
23
+ {{/supportsES6}}
24
+ "scripts": {
25
+ "build": "tsc{{#supportsES6}} && tsc -p tsconfig.esm.json{{/supportsES6}}",
26
+ "prepare": "npm run build"
27
+ },
28
+ "peerDependencies": {
29
+ "axios": "{{axiosVersion}}"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "12.11.5 - 12.20.42",
33
+ "axios": "{{axiosVersion}}",
34
+ "typescript": "^4.0 || ^5.0"
35
+ }{{#npmRepository}},{{/npmRepository}}
36
+ {{#npmRepository}}
37
+ "publishConfig": {
38
+ "registry": "{{npmRepository}}"
39
+ }
40
+ {{/npmRepository}}
41
+ }