@team-supercharge/oasg 15.2.0-typescript-axios-41a9a301.0 → 16.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 +54 -47
- package/bin/oasg +1 -2
- package/config.schema.yml +3 -18
- package/package.json +1 -1
- package/targets/nestjs/templates/auth.guard.mustache +18 -11
- package/targets/typescript-axios/generate.sh +0 -20
- package/targets/typescript-axios/generator-config.json +0 -20
- package/targets/typescript-axios/publish.sh +0 -8
- /package/targets/{python → python-legacy}/generate.sh +0 -0
- /package/targets/{python → python-legacy}/generator-config.json +0 -0
- /package/targets/{python → python-legacy}/publish.sh +0 -0
package/README.md
CHANGED
@@ -107,34 +107,33 @@ swaggerlint:
|
|
107
107
|
|
108
108
|
The table below gives an overview of the changes (breaking, non-breaking, bug fixes) introduced in various major versions. For the resolution of breaking changes please consult the [Migration Guide](#migration-guide).
|
109
109
|
|
110
|
-
| Component | | | | | | | | | | | | | | | |
|
111
|
-
|
112
|
-
| **Internal** | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|
113
|
-
| _Core_ |🐛 |💥 |✨ |🐛 |✨ |➖ |✨ |🐛 |🐛 |➖ |💥 |💥 |✨ |💥 |🆕 |
|
114
|
-
| _Linter_ |➖ |➖ |➖ |➖ |💥 |➖ |➖ |➖ |➖ |🐛 |➖ |✨ |💥 |🆕 |
|
115
|
-
| **Client Targets** | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|
116
|
-
| `android` |➖ |🐛 |💥 |➖ |➖ |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
117
|
-
| `angular` |➖ |🐛 |💥 |➖ |➖ |➖ |🐛 |➖ |➖ |➖ |💥 |➖ |➖ |➖ |🆕 |
|
118
|
-
| `dotnet` |➖ |🆕 |
|
119
|
-
| `feign` |➖ |➖ |➖ |➖ |➖ |✨ |💥 |💥 |➖ |➖ |🐛 |🐛 |🆕 |
|
120
|
-
| `feign-kotlin` |➖ |➖ |➖ |➖ |➖ |🆕 |
|
121
|
-
| `flutter` |➖ |➖ |🆕 |
|
122
|
-
| `ios` |➖ |➖ |💥 |🐛 |➖ |➖ |➖ |✨ |➖ |💥 |➖ |➖ |✨ |🆕 |
|
123
|
-
| `kmp` |➖ |🆕 |
|
124
|
-
| `python`
|
125
|
-
| `react` |🐛 |➖ |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
126
|
-
|
|
127
|
-
|
|
128
|
-
| `
|
129
|
-
| `python-fastapi`
|
130
|
-
| `
|
131
|
-
| `spring`
|
132
|
-
|
|
133
|
-
|
|
134
|
-
| `
|
135
|
-
| `
|
136
|
-
| `
|
137
|
-
| `postman` |🆕 |
|
110
|
+
| Component | | | | | | | | | | | | | | | | |
|
111
|
+
|------------------------------|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
112
|
+
| **Internal** | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|
113
|
+
| _Core_ |➖ |🐛 |💥 |✨ |🐛 |✨ |➖ |✨ |🐛 |🐛 |➖ |💥 |💥 |✨ |💥 |🆕 |
|
114
|
+
| _Linter_ |➖ |➖ |➖ |➖ |➖ |💥 |➖ |➖ |➖ |➖ |🐛 |➖ |✨ |💥 |🆕 |
|
115
|
+
| **Client Targets** | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|
116
|
+
| `android` |➖ |➖ |🐛 |💥 |➖ |➖ |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
117
|
+
| `angular` |➖ |➖ |🐛 |💥 |➖ |➖ |➖ |🐛 |➖ |➖ |➖ |💥 |➖ |➖ |➖ |🆕 |
|
118
|
+
| `dotnet` |➖ |➖ |🆕 |
|
119
|
+
| `feign` |➖ |➖ |➖ |➖ |➖ |➖ |✨ |💥 |💥 |➖ |➖ |🐛 |🐛 |🆕 |
|
120
|
+
| `feign-kotlin` |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
121
|
+
| `flutter` |➖ |➖ |➖ |🆕 |
|
122
|
+
| `ios` |➖ |➖ |➖ |💥 |🐛 |➖ |➖ |➖ |✨ |➖ |💥 |➖ |➖ |✨ |🆕 |
|
123
|
+
| `kmp` |➖ |➖ |🆕 |
|
124
|
+
| `python-legacy` |💥 |➖ |🐛 |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
125
|
+
| `react` |➖ |🐛 |➖ |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
126
|
+
| **Server Targets** | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|
127
|
+
| `nestjs` |💥 |💥 |➖ |💥 |✨ |➖ |➖ |🐛 |➖ |➖ |✨ |🆕 |
|
128
|
+
| `python-fastapi` |➖ |➖ |🆕 |
|
129
|
+
| `python-fastapi-raw-request` |➖ |➖ |🆕 |
|
130
|
+
| `spring` |➖ |➖ |➖ |➖ |➖ |➖ |✨ |💥 |💥 |➖ |➖ |➖ |✨ |➖ |🆕 |
|
131
|
+
| `spring-kotlin` |➖ |➖ |➖ |➖ |➖ |➖ |✨ |💥 |💥 |➖ |➖ |🐛 |✨ |➖ |🆕 |
|
132
|
+
| **Misc Targets** | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|
133
|
+
| `contract-testing` |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
134
|
+
| `openapi` |➖ |➖ |➖ |➖ |💥 |➖ |➖ |✨ |➖ |🆕 |
|
135
|
+
| `stubby` |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |💥 |➖ |➖ |➖ |➖ |🆕 |
|
136
|
+
| `postman` |➖ |🆕 |
|
138
137
|
|
139
138
|
**Legend:**
|
140
139
|
|
@@ -721,12 +720,12 @@ TBD
|
|
721
720
|
| formatterCustomArgs | Custom arguments of the `ktlint` formatter | N | --disabled_rules=no-wildcard-imports,max-line-length,enum-entry-name-case |
|
722
721
|
| repository | URL of the Maven Repository | N | - |
|
723
722
|
|
724
|
-
#### `python`
|
723
|
+
#### `python-legacy`
|
725
724
|
|
726
725
|
```json
|
727
726
|
{
|
728
|
-
"id": "client-python",
|
729
|
-
"type": "python",
|
727
|
+
"id": "client-python-legacy",
|
728
|
+
"type": "python-legacy",
|
730
729
|
"source": "source-merged",
|
731
730
|
"packageName": "oasg_example",
|
732
731
|
"repositoryUrl": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/pypi"
|
@@ -738,6 +737,8 @@ TBD
|
|
738
737
|
| packageName | Package nem for the project (convention: snake_case) | Y | - |
|
739
738
|
| repositoryUrl | URL of the PyPI repository | Y | - |
|
740
739
|
|
740
|
+
> ⚠️ Using Pydantic v1 for legacy reasons, this target will be discontinued.
|
741
|
+
|
741
742
|
Publishing the PyPI packages is done with Twine. For authentication against the PiPI repository you need to set the `TWINE_USERNAME` and `TWINE_PASSWORD` environment variables.
|
742
743
|
|
743
744
|
|
@@ -995,28 +996,34 @@ Validations from OpenAPI spec:
|
|
995
996
|
|-|-|-|-|
|
996
997
|
| fileName | Name of the generated file | N | `collection.json` |
|
997
998
|
|
998
|
-
|
999
|
+
---
|
999
1000
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1001
|
+
# Migration Guide
|
1002
|
+
|
1003
|
+
This section covers the breaking changes and their migrations across major version upgrades.
|
1004
|
+
|
1005
|
+
## From `15.x.x` to `16.0.0`
|
1006
|
+
|
1007
|
+
### Breaking in `nestjs` target
|
1008
|
+
|
1009
|
+
In the `nestjs` target the `AuthServiceInterface` needed to be implemented in projects got changed from:
|
1010
|
+
|
1011
|
+
```typescript
|
1012
|
+
validate: (scheme: SecurityScheme, request: any) => boolean | Promise<boolean> | Observable<boolean>;
|
1008
1013
|
```
|
1009
1014
|
|
1010
|
-
|
1011
|
-
|-|-|-|-|
|
1012
|
-
| packageName | Name of the generated NPM package | Y | - |
|
1013
|
-
| repository | URL of the NPM package registry | Y | - |
|
1015
|
+
to
|
1014
1016
|
|
1015
|
-
|
1017
|
+
```typescript
|
1018
|
+
validate: (scheme: SecurityScheme, context: ExecutionContext) => boolean | Promise<boolean> | Observable<boolean>;
|
1019
|
+
```
|
1016
1020
|
|
1017
|
-
|
1021
|
+
in order to provide compabilitity with existing Nest guards
|
1022
|
+
|
1023
|
+
### Breaking in `python` target
|
1024
|
+
|
1025
|
+
From this version the `python` target got renamed to `python-legacy` to reflect the same changes in __OpenAPI Generator__ where starting from version 7.1.0 the `python-pydantic-v1` generator outputs the "legacy compatible" code, and the ongoing `python` generator got updated to support Pydantic v2.
|
1018
1026
|
|
1019
|
-
This section covers the breaking changes and their migrations across major version upgrades.
|
1020
1027
|
|
1021
1028
|
## From `14.x.x` to `15.0.0`
|
1022
1029
|
|
package/bin/oasg
CHANGED
@@ -42,9 +42,8 @@ const DEFAULT_GENERATOR_MAPPING = {
|
|
42
42
|
"flutter": { version: '7.0.1', generator: 'dart-dio' },
|
43
43
|
"ios": { version: '7.0.1', generator: 'swift5' },
|
44
44
|
"kmp": { version: '7.8.0', generator: 'kotlin' },
|
45
|
-
"python":
|
45
|
+
"python-legacy": { version: '7.11.0', generator: 'python-pydantic-v1' },
|
46
46
|
"react": { version: '7.0.1', generator: 'typescript-fetch' },
|
47
|
-
"typescript-axios": { version: '7.11.0', generator: 'typescript-axios' },
|
48
47
|
// server targets
|
49
48
|
"nestjs": { version: '7.0.1', generator: 'typescript-angular' },
|
50
49
|
"spring": { version: '7.0.1', generator: 'spring' },
|
package/config.schema.yml
CHANGED
@@ -19,7 +19,7 @@ properties:
|
|
19
19
|
- $ref: '#/targets/Stubby'
|
20
20
|
- $ref: '#/targets/Android'
|
21
21
|
- $ref: '#/targets/ios'
|
22
|
-
- $ref: '#/targets/
|
22
|
+
- $ref: '#/targets/PythonLegacy'
|
23
23
|
- $ref: '#/targets/PythonFastApi'
|
24
24
|
- $ref: '#/targets/PythonFastApiRawRequest'
|
25
25
|
- $ref: '#/targets/ContractTesting'
|
@@ -29,7 +29,6 @@ properties:
|
|
29
29
|
- $ref: '#/targets/Kmp'
|
30
30
|
- $ref: '#/targets/Dotnet'
|
31
31
|
- $ref: '#/targets/Postman'
|
32
|
-
- $ref: '#/targets/TypeScriptAxios'
|
33
32
|
required:
|
34
33
|
- targets
|
35
34
|
additionalProperties: false
|
@@ -287,12 +286,12 @@ targets:
|
|
287
286
|
- repository
|
288
287
|
- interfaceType
|
289
288
|
|
290
|
-
|
289
|
+
PythonLegacy:
|
291
290
|
allOf:
|
292
291
|
- $ref: '#/targets/Base'
|
293
292
|
- properties:
|
294
293
|
type:
|
295
|
-
pattern: "^python$"
|
294
|
+
pattern: "^python-legacy$"
|
296
295
|
packageName:
|
297
296
|
type: string
|
298
297
|
repositoryUrl:
|
@@ -357,20 +356,6 @@ targets:
|
|
357
356
|
- packageName
|
358
357
|
- repository
|
359
358
|
|
360
|
-
TypeScriptAxios:
|
361
|
-
allOf:
|
362
|
-
- $ref: '#/targets/Base'
|
363
|
-
- properties:
|
364
|
-
type:
|
365
|
-
pattern: "^typescript-axios$"
|
366
|
-
packageName:
|
367
|
-
type: string
|
368
|
-
repository:
|
369
|
-
type: string
|
370
|
-
required:
|
371
|
-
- packageName
|
372
|
-
- repository
|
373
|
-
|
374
359
|
OpenAPI:
|
375
360
|
allOf:
|
376
361
|
- $ref: '#/targets/Base'
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@team-supercharge/oasg",
|
3
|
-
"version": "
|
3
|
+
"version": "16.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",
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
UnauthorizedException,
|
7
7
|
} from "@nestjs/common";
|
8
8
|
import { Reflector } from "@nestjs/core";
|
9
|
-
import { Observable } from "rxjs";
|
9
|
+
import { firstValueFrom, isObservable, Observable } from "rxjs";
|
10
10
|
|
11
11
|
// export securityScheme names as enum
|
12
12
|
export enum SecurityScheme { {{#authMethods}}
|
@@ -17,11 +17,7 @@ export enum SecurityScheme { {{#authMethods}}
|
|
17
17
|
export const AuthSchemes = Reflector.createDecorator<SecurityScheme[]>();
|
18
18
|
|
19
19
|
export interface AuthServiceInterface {
|
20
|
-
validate: (
|
21
|
-
scheme: SecurityScheme,
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
23
|
-
request: any
|
24
|
-
) => boolean | Promise<boolean> | Observable<boolean>;
|
20
|
+
validate: (scheme: SecurityScheme, context: ExecutionContext) => boolean | Promise<boolean> | Observable<boolean>;
|
25
21
|
}
|
26
22
|
|
27
23
|
export const AUTH_SERVICE_TOKEN = "OASG_AUTH_SERVICE";
|
@@ -34,15 +30,26 @@ export class AuthGuard implements CanActivate {
|
|
34
30
|
private readonly reflector: Reflector
|
35
31
|
) {}
|
36
32
|
|
37
|
-
canActivate(
|
38
|
-
context: ExecutionContext
|
39
|
-
): boolean | Promise<boolean> | Observable<boolean> {
|
33
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
40
34
|
const schemes = this.reflector.get<SecurityScheme[]>(AuthSchemes, context.getHandler());
|
41
|
-
const request = context.switchToHttp().getRequest();
|
42
35
|
|
43
|
-
|
36
|
+
const validationResults = await Promise.all(schemes
|
37
|
+
.map((scheme) => this.authService.validate(scheme, context))
|
38
|
+
.map((validationResult) => this.extractValidationResultAsPromise(validationResult))
|
39
|
+
);
|
40
|
+
|
41
|
+
if (validationResults.some((result) => result)) {
|
44
42
|
return true;
|
43
|
+
}
|
45
44
|
|
46
45
|
throw new UnauthorizedException();
|
47
46
|
}
|
47
|
+
|
48
|
+
private async extractValidationResultAsPromise(validationResult: boolean | Promise<boolean> | Observable<boolean> ): Promise<boolean> {
|
49
|
+
if (isObservable(validationResult)) {
|
50
|
+
return firstValueFrom(validationResult);
|
51
|
+
}
|
52
|
+
|
53
|
+
return validationResult;
|
54
|
+
}
|
48
55
|
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
#/bin/bash
|
2
|
-
|
3
|
-
source $(dirname "$0")/../common.sh
|
4
|
-
|
5
|
-
rm -rf out/$targetId
|
6
|
-
mkdir -p out/$targetId
|
7
|
-
|
8
|
-
java -jar $binary generate \
|
9
|
-
-g $generatorId \
|
10
|
-
-i $openApiFile \
|
11
|
-
-t $templateDir \
|
12
|
-
-o out/$targetId \
|
13
|
-
-c $(dirname "$0")/generator-config.json \
|
14
|
-
-p "npmVersion=$version,npmName=$packageName,npmRepository=$repository" $generatorCustomArgs
|
15
|
-
|
16
|
-
cd out/$targetId
|
17
|
-
|
18
|
-
npm install
|
19
|
-
npm run build
|
20
|
-
cd ../..
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"modelPropertyNaming": "original",
|
3
|
-
"supportsES6": "true",
|
4
|
-
"providedInRoot": "true",
|
5
|
-
"ngVersion": "10.0.2",
|
6
|
-
"serviceSuffix": "Api",
|
7
|
-
"serviceFileSuffix": ".api",
|
8
|
-
"stringEnums": "true",
|
9
|
-
"enumPropertyNaming": "UPPERCASE",
|
10
|
-
"fileNaming": "kebab-case",
|
11
|
-
"useSingleRequestParameter": "false",
|
12
|
-
"sortModelPropertiesByRequiredFlag": "false",
|
13
|
-
"sortParamsByRequiredFlag": "true",
|
14
|
-
"inlineSchemaOptions": {
|
15
|
-
"ARRAY_ITEM_SUFFIX": "",
|
16
|
-
"MAP_ITEM_SUFFIX": "",
|
17
|
-
"SKIP_SCHEMA_REUSE": "true",
|
18
|
-
"RESOLVE_INLINE_ENUMS": "true"
|
19
|
-
}
|
20
|
-
}
|
File without changes
|
File without changes
|
File without changes
|