@team-supercharge/oasg 16.2.0 → 16.3.0-feature-aspdotnetcore-generator-1e9d3b5d.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 +21 -0
- package/bin/merger.js +5 -1
- package/bin/oasg +2 -1
- package/bin/process-source.js +31 -1
- package/config.schema.yml +18 -0
- package/package.json +1 -1
- package/targets/dotnet-webapi/generate.sh +15 -0
- package/targets/dotnet-webapi/generator-config.json +23 -0
- package/targets/dotnet-webapi/publish.sh +23 -0
package/README.md
CHANGED
@@ -1006,6 +1006,27 @@ Validations from OpenAPI spec:
|
|
1006
1006
|
| packageName | Name of the generated package | Y | - |
|
1007
1007
|
| generatorCustomArgs | Custom arguments of the generator (--global-property, --additional-properties) | N | - |
|
1008
1008
|
|
1009
|
+
#### `dotnet-webapi`
|
1010
|
+
|
1011
|
+
```json
|
1012
|
+
{
|
1013
|
+
"id": "dotnet-webapi",
|
1014
|
+
"type": "dotnet-webapi",
|
1015
|
+
"source": "source-merged",
|
1016
|
+
"sourceUrl": "https://api.nuget.org/v3/index.json",
|
1017
|
+
"apiKey": "apiKey",
|
1018
|
+
"packageName": "packageName",
|
1019
|
+
"generatorCustomArgs": "--global-property=supportingFiles,modelDocs --additional-properties=nullableReferenceTypes=false"
|
1020
|
+
}
|
1021
|
+
```
|
1022
|
+
|
1023
|
+
| Parameter | Description | Required | Default |
|
1024
|
+
| ------------------- | ------------------------------------------------------------------------------ | -------- | ------- |
|
1025
|
+
| sourceUrl | Url to where the package will be published | Y | - |
|
1026
|
+
| apiKey | Api key of nuget source | Y | - |
|
1027
|
+
| packageName | Name of the generated package | Y | - |
|
1028
|
+
| generatorCustomArgs | Custom arguments of the generator (--global-property, --additional-properties) | N | - |
|
1029
|
+
|
1009
1030
|
#### `postman`
|
1010
1031
|
|
1011
1032
|
```json
|
package/bin/merger.js
CHANGED
@@ -181,12 +181,16 @@ function updateReferences(document, oldValue, newValue) {
|
|
181
181
|
|
182
182
|
function mergeDocument(leftDoc, rightDoc) {
|
183
183
|
// not overriding: info, externalDocs (always from first file)
|
184
|
-
// not merging: servers,
|
184
|
+
// not merging: servers, security
|
185
185
|
|
186
186
|
// paths
|
187
187
|
const mergedPaths = { ...leftDoc.paths, ...rightDoc.paths };
|
188
188
|
leftDoc.paths = mergedPaths;
|
189
189
|
|
190
|
+
// webhooks
|
191
|
+
const mergedWebhooks = { ...leftDoc.webhooks, ...rightDoc.webhooks };
|
192
|
+
leftDoc.webhooks = mergedWebhooks;
|
193
|
+
|
190
194
|
// components
|
191
195
|
const mergedSchemas = { ...leftDoc.components.schemas, ...rightDoc.components.schemas };
|
192
196
|
const mergedResponses = { ...leftDoc.components.responses, ...rightDoc.components.responses };
|
package/bin/oasg
CHANGED
@@ -36,7 +36,7 @@ const PROXY_PORT = '9999';
|
|
36
36
|
const DEFAULT_GENERATOR_MAPPING = {
|
37
37
|
// client targets
|
38
38
|
"android": { version: '7.0.1', generator: 'kotlin' },
|
39
|
-
"angular": { version: '7.0
|
39
|
+
"angular": { version: '7.11.0', generator: 'typescript-angular' },
|
40
40
|
"feign": { version: '7.0.1', generator: 'spring' },
|
41
41
|
"feign-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
|
42
42
|
"flutter": { version: '7.0.1', generator: 'dart-dio' },
|
@@ -54,6 +54,7 @@ const DEFAULT_GENERATOR_MAPPING = {
|
|
54
54
|
"python-fastapi": { version: '7.8.0', generator: 'python-fastapi' },
|
55
55
|
"python-fastapi-raw-request": { version: '7.0.1', generator: 'python-fastapi' },
|
56
56
|
"dotnet": { version: '7.8.0', generator: 'csharp-functions' },
|
57
|
+
"dotnet-webapi": { version: '7.8.0', generator: 'aspnetcore' },
|
57
58
|
// misc targets
|
58
59
|
"contract-testing": { version: '4.3.1', generator: 'typescript-node' },
|
59
60
|
"openapi": { version: undefined, generator: undefined },
|
package/bin/process-source.js
CHANGED
@@ -69,13 +69,14 @@ async function processSource(source, sourceFile, version) {
|
|
69
69
|
// clean up unused things
|
70
70
|
if (source.cleanup) {
|
71
71
|
const removedPaths = [];
|
72
|
+
const removedWebhooks = [];
|
72
73
|
const removedTags = [];
|
73
74
|
const usedTags = [];
|
74
75
|
|
75
76
|
// remove empty paths & gather tags
|
76
77
|
const paths = document.paths || {};
|
77
78
|
for (const pathKey in paths) {
|
78
|
-
const path =
|
79
|
+
const path = paths[pathKey];
|
79
80
|
|
80
81
|
if (Object.keys(path).length === 0) {
|
81
82
|
removedPaths.push(pathKey);
|
@@ -97,10 +98,39 @@ async function processSource(source, sourceFile, version) {
|
|
97
98
|
}
|
98
99
|
}
|
99
100
|
|
101
|
+
// remove empty webhooks & gather tags
|
102
|
+
const webhooks = document.webhooks || {};
|
103
|
+
for (const webhookKey in webhooks) {
|
104
|
+
const webhook = webhooks[webhookKey];
|
105
|
+
|
106
|
+
if (Object.keys(webhook).length === 0) {
|
107
|
+
removedWebhooks.push(webhookKey);
|
108
|
+
delete webhooks[webhookKey];
|
109
|
+
}
|
110
|
+
|
111
|
+
for (const methodKey in webhook) {
|
112
|
+
const maybeOperation = webhook[methodKey];
|
113
|
+
|
114
|
+
if (!maybeOperation.tags) {
|
115
|
+
continue;
|
116
|
+
}
|
117
|
+
|
118
|
+
maybeOperation.tags.forEach(tag => {
|
119
|
+
if (!usedTags.includes(tag)) {
|
120
|
+
usedTags.push(tag);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
100
126
|
if (removedPaths.length !== 0) {
|
101
127
|
console.log(`cleaned up unused paths:\n ${removedPaths.join('\n ')}`);
|
102
128
|
}
|
103
129
|
|
130
|
+
if (removedWebhooks.length !== 0) {
|
131
|
+
console.log(`cleaned up unused webhooks:\n ${removedWebhooks.join('\n ')}`);
|
132
|
+
}
|
133
|
+
|
104
134
|
// remouve unused tags
|
105
135
|
const tags = [...document.tags];
|
106
136
|
tags.forEach(tag => {
|
package/config.schema.yml
CHANGED
@@ -29,6 +29,7 @@ properties:
|
|
29
29
|
- $ref: '#/targets/Flutter'
|
30
30
|
- $ref: '#/targets/Kmp'
|
31
31
|
- $ref: '#/targets/Dotnet'
|
32
|
+
- $ref: '#/targets/DotnetWebApi'
|
32
33
|
- $ref: '#/targets/Postman'
|
33
34
|
- $ref: '#/targets/TypeScriptAxios'
|
34
35
|
- $ref: '#/targets/TypeScriptFetch'
|
@@ -413,6 +414,23 @@ targets:
|
|
413
414
|
- apiKey
|
414
415
|
- packageName
|
415
416
|
|
417
|
+
DotnetWebApi:
|
418
|
+
allOf:
|
419
|
+
- $ref: '#/targets/Base'
|
420
|
+
- properties:
|
421
|
+
type:
|
422
|
+
pattern: '^dotnet-webapi$'
|
423
|
+
sourceUrl:
|
424
|
+
type: string
|
425
|
+
apiKey:
|
426
|
+
type: string
|
427
|
+
packageName:
|
428
|
+
type: string
|
429
|
+
required:
|
430
|
+
- sourceUrl
|
431
|
+
- apiKey
|
432
|
+
- packageName
|
433
|
+
|
416
434
|
Kmp:
|
417
435
|
allOf:
|
418
436
|
- $ref: '#/targets/Base'
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@team-supercharge/oasg",
|
3
|
-
"version": "16.
|
3
|
+
"version": "16.3.0-feature-aspdotnetcore-generator-1e9d3b5d.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",
|
@@ -0,0 +1,15 @@
|
|
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 "packageVersion=$version,packageName=$packageName" \
|
15
|
+
$generatorCustomArgs
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"inlineSchemaOptions": {
|
3
|
+
"ARRAY_ITEM_SUFFIX": "",
|
4
|
+
"MAP_ITEM_SUFFIX": "",
|
5
|
+
"SKIP_SCHEMA_REUSE": "true"
|
6
|
+
},
|
7
|
+
"globalProperties": {
|
8
|
+
"models": "",
|
9
|
+
"supportingFiles": "",
|
10
|
+
"modelDocs": ""
|
11
|
+
},
|
12
|
+
"additionalProperties": {
|
13
|
+
"aspnetCoreVersion": "8.0",
|
14
|
+
"operationIsAsync": true,
|
15
|
+
"buildTarget": "library",
|
16
|
+
"generateBody": false,
|
17
|
+
"useDateTimeOffset": true,
|
18
|
+
"nullableReferenceTypes": true,
|
19
|
+
"operationResultTask": true,
|
20
|
+
"enumNameSuffix": "",
|
21
|
+
"enumValueSuffix": ""
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
source $(dirname "$0")/../common.sh
|
4
|
+
|
5
|
+
cd out/$targetId
|
6
|
+
|
7
|
+
# pack
|
8
|
+
dotnet restore
|
9
|
+
dotnet build -c Release
|
10
|
+
dotnet pack -c Release -p:Version=$version -p:IsPackable=true
|
11
|
+
|
12
|
+
isWindows=false
|
13
|
+
if [[ "$OSTYPE" == "cygwin"* ]] || [[ "$OSTYPE" == "msys"* ]]; then
|
14
|
+
isWindows=true
|
15
|
+
fi
|
16
|
+
storePasswordOption=$([[ $isWindows == true ]] && echo "" || echo "--store-password-in-clear-text")
|
17
|
+
|
18
|
+
# publish
|
19
|
+
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration></configuration>" > nuget.config
|
20
|
+
dotnet nuget add source "${sourceUrl}" -n Feed -u User -p "${apiKey}" --configfile nuget.config $storePasswordOption
|
21
|
+
dotnet nuget push "src/**/bin/Release/*.nupkg" -s ${sourceUrl} -k AZ
|
22
|
+
|
23
|
+
cd ../..
|