@team-supercharge/oasg 16.7.1 → 16.8.1
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 +41 -0
- package/bin/oasg +7 -2
- package/config.schema.yml +32 -0
- package/package.json +1 -1
- package/targets/apple-swift/generate.sh +30 -0
- package/targets/apple-swift/publish.sh +33 -0
- package/targets/apple-swift/templates/Package.swift +36 -0
- package/targets/apple-swift/templates/openapi-generator-config-client.yaml +5 -0
- package/targets/apple-swift/templates/openapi-generator-config-server.yaml +5 -0
- package/targets/dotnet/publish.sh +7 -9
- package/targets/dotnet-webapi/generate.sh +15 -0
- package/targets/dotnet-webapi/generator-config.json +17 -0
- package/targets/dotnet-webapi/publish.sh +21 -0
- package/targets/dotnet-webapi/templates/model.mustache +198 -0
- package/targets/nestjs/templates/api.service.mustache +1 -1
package/README.md
CHANGED
@@ -142,6 +142,7 @@ The table below gives an overview of the changes (breaking, non-breaking, bug fi
|
|
142
142
|
| `plain-java` |🆕 |
|
143
143
|
| `flutter` |➖ |➖ |➖ |🆕 |
|
144
144
|
| `ios` |➖ |➖ |➖ |💥 |🐛 |➖ |➖ |➖ |✨ |➖ |💥 |➖ |➖ |✨ |🆕 |
|
145
|
+
| `apple-swift` |🆕 |
|
145
146
|
| `kmp` |➖ |➖ |🆕 |
|
146
147
|
| `python` |🆕 |
|
147
148
|
| `python-legacy` |💥 |➖ |🐛 |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
|
@@ -701,6 +702,25 @@ TBD
|
|
701
702
|
| interfaceType | Response type of the generated client: `Combine` / `Result` / `RxSwift` / `AsyncAwait` / `PromiseKit` | Y | - |
|
702
703
|
| generatorCustomArgs | Custom arguments of the generator | N | - |
|
703
704
|
|
705
|
+
#### `apple-swift`
|
706
|
+
|
707
|
+
```json
|
708
|
+
{
|
709
|
+
"id": "client-ios",
|
710
|
+
"type": "apple-swift",
|
711
|
+
"source": "source-merged",
|
712
|
+
"projectName": "OASgExample",
|
713
|
+
"repository": "git@gitlab.supercharge.io:example/openapi-generator-source.git",
|
714
|
+
"generatorCustomArgs": ""
|
715
|
+
}
|
716
|
+
```
|
717
|
+
|
718
|
+
|Parameter| Description| Required | Default |
|
719
|
+
|-|-|-|-|
|
720
|
+
| projectName | Name of the project | Y | - |
|
721
|
+
| repository | URL of the generated client api code repository | Y | - |
|
722
|
+
| generatorCustomArgs | Custom arguments of the generator | N | - |
|
723
|
+
|
704
724
|
#### `flutter`
|
705
725
|
|
706
726
|
```json
|
@@ -1028,6 +1048,27 @@ Validations from OpenAPI spec:
|
|
1028
1048
|
| packageName | Name of the generated package | Y | - |
|
1029
1049
|
| generatorCustomArgs | Custom arguments of the generator (--global-property, --additional-properties) | N | - |
|
1030
1050
|
|
1051
|
+
#### `dotnet-webapi`
|
1052
|
+
|
1053
|
+
```json
|
1054
|
+
{
|
1055
|
+
"id": "dotnet-webapi",
|
1056
|
+
"type": "dotnet-webapi",
|
1057
|
+
"source": "source-merged",
|
1058
|
+
"sourceUrl": "https://api.nuget.org/v3/index.json",
|
1059
|
+
"apiKey": "apiKey",
|
1060
|
+
"packageName": "packageName",
|
1061
|
+
"generatorCustomArgs": "--global-property=supportingFiles,modelDocs --additional-properties=nullableReferenceTypes=false"
|
1062
|
+
}
|
1063
|
+
```
|
1064
|
+
|
1065
|
+
| Parameter | Description | Required | Default |
|
1066
|
+
| ------------------- | ------------------------------------------------------------------------------ | -------- | ------- |
|
1067
|
+
| sourceUrl | Url to where the package will be published | Y | - |
|
1068
|
+
| packageName | Name of the generated package | Y | - |
|
1069
|
+
| apiKey | Api key of nuget source (If not specified, provide the CI_JOB_TOKEN) | N | - |
|
1070
|
+
| generatorCustomArgs | Custom arguments of the generator (--global-property, --additional-properties) | N | - |
|
1071
|
+
|
1031
1072
|
#### `postman`
|
1032
1073
|
|
1033
1074
|
```json
|
package/bin/oasg
CHANGED
@@ -42,6 +42,7 @@ const DEFAULT_GENERATOR_MAPPING = {
|
|
42
42
|
"plain-java": { version: '7.11.0', generator: 'java' },
|
43
43
|
"flutter": { version: '7.0.1', generator: 'dart-dio' },
|
44
44
|
"ios": { version: '7.0.1', generator: 'swift5' },
|
45
|
+
"apple-swift": { version: undefined, generator: undefined },
|
45
46
|
"kmp": { version: '7.8.0', generator: 'kotlin' },
|
46
47
|
"python": { version: '7.11.0', generator: 'python' },
|
47
48
|
"python-legacy": { version: '7.11.0', generator: 'python-pydantic-v1' },
|
@@ -54,7 +55,8 @@ const DEFAULT_GENERATOR_MAPPING = {
|
|
54
55
|
"spring-kotlin": { version: '7.11.0', generator: 'kotlin-spring' },
|
55
56
|
"python-fastapi": { version: '7.8.0', generator: 'python-fastapi' },
|
56
57
|
"python-fastapi-raw-request": { version: '7.0.1', generator: 'python-fastapi' },
|
57
|
-
"dotnet": { version: '7.
|
58
|
+
"dotnet": { version: '7.11.0', generator: 'csharp-functions' },
|
59
|
+
"dotnet-webapi": { version: '7.11.0', generator: 'aspnetcore' },
|
58
60
|
// misc targets
|
59
61
|
"contract-testing": { version: '4.3.1', generator: 'typescript-node' },
|
60
62
|
"openapi": { version: undefined, generator: undefined },
|
@@ -551,7 +553,10 @@ function fetchBinary(target) {
|
|
551
553
|
const generator = target.generator
|
552
554
|
const binary = {};
|
553
555
|
|
554
|
-
if (generator
|
556
|
+
if (generator === undefined) {
|
557
|
+
return '/dev/null';
|
558
|
+
}
|
559
|
+
else if (generator.startsWith('http')) {
|
555
560
|
binary.url = generator;
|
556
561
|
|
557
562
|
const hash = crypto.createHash('sha256').update(binary.url).digest('hex').substring(0, 8);
|
package/config.schema.yml
CHANGED
@@ -20,6 +20,7 @@ properties:
|
|
20
20
|
- $ref: '#/targets/Stubby'
|
21
21
|
- $ref: '#/targets/Android'
|
22
22
|
- $ref: '#/targets/ios'
|
23
|
+
- $ref: '#/targets/AppleSwift'
|
23
24
|
- $ref: '#/targets/Python'
|
24
25
|
- $ref: '#/targets/PythonLegacy'
|
25
26
|
- $ref: '#/targets/PythonFastApi'
|
@@ -30,6 +31,7 @@ properties:
|
|
30
31
|
- $ref: '#/targets/Flutter'
|
31
32
|
- $ref: '#/targets/Kmp'
|
32
33
|
- $ref: '#/targets/Dotnet'
|
34
|
+
- $ref: '#/targets/DotnetWebApi'
|
33
35
|
- $ref: '#/targets/Postman'
|
34
36
|
- $ref: '#/targets/TypeScriptAxios'
|
35
37
|
- $ref: '#/targets/TypeScriptFetch'
|
@@ -312,6 +314,20 @@ targets:
|
|
312
314
|
- repository
|
313
315
|
- interfaceType
|
314
316
|
|
317
|
+
AppleSwift:
|
318
|
+
allOf:
|
319
|
+
- $ref: '#/targets/Base'
|
320
|
+
- properties:
|
321
|
+
type:
|
322
|
+
pattern: "^apple-swift$"
|
323
|
+
projectName:
|
324
|
+
type: string
|
325
|
+
repository:
|
326
|
+
type: string
|
327
|
+
required:
|
328
|
+
- projectName
|
329
|
+
- repository
|
330
|
+
|
315
331
|
Python:
|
316
332
|
allOf:
|
317
333
|
- $ref: '#/targets/Base'
|
@@ -436,6 +452,22 @@ targets:
|
|
436
452
|
- apiKey
|
437
453
|
- packageName
|
438
454
|
|
455
|
+
DotnetWebApi:
|
456
|
+
allOf:
|
457
|
+
- $ref: '#/targets/Base'
|
458
|
+
- properties:
|
459
|
+
type:
|
460
|
+
pattern: '^dotnet-webapi$'
|
461
|
+
sourceUrl:
|
462
|
+
type: string
|
463
|
+
apiKey:
|
464
|
+
type: string
|
465
|
+
packageName:
|
466
|
+
type: string
|
467
|
+
required:
|
468
|
+
- sourceUrl
|
469
|
+
- packageName
|
470
|
+
|
439
471
|
Kmp:
|
440
472
|
allOf:
|
441
473
|
- $ref: '#/targets/Base'
|
package/package.json
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
#/bin/bash
|
2
|
+
|
3
|
+
source $(dirname "$0")/../common.sh
|
4
|
+
|
5
|
+
# Clear the output directory
|
6
|
+
rm -rf out/$targetId
|
7
|
+
mkdir -p out/$targetId
|
8
|
+
|
9
|
+
# Generate swift code from OpenAPI spec
|
10
|
+
swift-openapi-generator \
|
11
|
+
generate \
|
12
|
+
--config "$templateDir/openapi-generator-config-client.yaml" \
|
13
|
+
--output-directory "out/$targetId/Sources/$projectName" \
|
14
|
+
"$openApiFile"
|
15
|
+
|
16
|
+
swift-openapi-generator \
|
17
|
+
generate \
|
18
|
+
--config "$templateDir/openapi-generator-config-server.yaml" \
|
19
|
+
--output-directory "out/$targetId/Sources/${projectName}Server" \
|
20
|
+
"$openApiFile"
|
21
|
+
|
22
|
+
# Copy Package.swift file
|
23
|
+
cp "$templateDir/Package.swift" "out/$targetId/"
|
24
|
+
|
25
|
+
# Replace the placeholder in Package.swift with the project name
|
26
|
+
if [[ "$(uname -s)" == "Darwin"* ]]; then
|
27
|
+
sed -i '' "s/__PROJECT_NAME__/$projectName/" "out/$targetId/Package.swift"
|
28
|
+
else
|
29
|
+
sed -i "s/__PROJECT_NAME__/$projectName/" "out/$targetId/Package.swift"
|
30
|
+
fi
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#/bin/bash
|
2
|
+
|
3
|
+
source $(dirname "$0")/../common.sh
|
4
|
+
|
5
|
+
cd out
|
6
|
+
git clone $repository generator-source
|
7
|
+
|
8
|
+
# Remove all old files from the generator-source directory
|
9
|
+
cd generator-source
|
10
|
+
git rm -rf .
|
11
|
+
git clean -fdx
|
12
|
+
cd ..
|
13
|
+
|
14
|
+
# Copy the generated files to the generator-source directory
|
15
|
+
cp -rf $targetId/* generator-source
|
16
|
+
|
17
|
+
cd generator-source
|
18
|
+
if [ $(git status --porcelain | wc -l) -eq "0" ]; then
|
19
|
+
echo "🟢 No changes"
|
20
|
+
else
|
21
|
+
git add .
|
22
|
+
git commit -m "chore(release): $version"
|
23
|
+
|
24
|
+
if [ "$preRelease" == "false" ]; then git push; fi
|
25
|
+
|
26
|
+
tagVersion="v$version"
|
27
|
+
git tag -f $tagVersion
|
28
|
+
git push origin -f --tags
|
29
|
+
fi
|
30
|
+
|
31
|
+
cd ..
|
32
|
+
rm -rf generator-source
|
33
|
+
cd ../..
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// swift-tools-version: 6.0
|
2
|
+
import PackageDescription
|
3
|
+
|
4
|
+
let package = Package(
|
5
|
+
name: "__PROJECT_NAME__",
|
6
|
+
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
|
7
|
+
products: [
|
8
|
+
.library(
|
9
|
+
name: "__PROJECT_NAME__",
|
10
|
+
targets: ["__PROJECT_NAME__"]
|
11
|
+
),
|
12
|
+
.library(
|
13
|
+
name: "__PROJECT_NAME__Server",
|
14
|
+
targets: ["__PROJECT_NAME__Server"]
|
15
|
+
)
|
16
|
+
],
|
17
|
+
dependencies: [
|
18
|
+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
|
19
|
+
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
|
20
|
+
],
|
21
|
+
targets: [
|
22
|
+
.target(
|
23
|
+
name: "__PROJECT_NAME__",
|
24
|
+
dependencies: [
|
25
|
+
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
|
26
|
+
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
|
27
|
+
]
|
28
|
+
),
|
29
|
+
.target(
|
30
|
+
name: "__PROJECT_NAME__Server",
|
31
|
+
dependencies: [
|
32
|
+
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
|
33
|
+
]
|
34
|
+
),
|
35
|
+
]
|
36
|
+
)
|
@@ -4,20 +4,18 @@ source $(dirname "$0")/../common.sh
|
|
4
4
|
|
5
5
|
cd out/$targetId
|
6
6
|
|
7
|
+
# install dotnet
|
8
|
+
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
|
9
|
+
chmod +x dotnet-install.sh
|
10
|
+
./dotnet-install.sh --channel 6.0 --install-dir "$HOME/.dotnet"
|
11
|
+
export PATH="$HOME/.dotnet:$PATH"
|
12
|
+
|
7
13
|
# pack
|
8
14
|
dotnet restore
|
9
15
|
dotnet build -c Release
|
10
16
|
dotnet pack -c Release -p:Version=$version -p:IsPackable=true
|
11
17
|
|
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
18
|
# publish
|
19
|
-
|
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
|
19
|
+
dotnet nuget push "src/**/bin/Release/*.nupkg" --source $sourceUrl -k ${apiKey:-$CI_JOB_TOKEN}
|
22
20
|
|
23
21
|
cd ../..
|
@@ -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,17 @@
|
|
1
|
+
{
|
2
|
+
"inlineSchemaOptions": {
|
3
|
+
"ARRAY_ITEM_SUFFIX": "",
|
4
|
+
"MAP_ITEM_SUFFIX": "",
|
5
|
+
"SKIP_SCHEMA_REUSE": "true"
|
6
|
+
},
|
7
|
+
"additionalProperties": {
|
8
|
+
"aspnetCoreVersion": "8.0",
|
9
|
+
"operationIsAsync": true,
|
10
|
+
"buildTarget": "library",
|
11
|
+
"generateBody": false,
|
12
|
+
"nullableReferenceTypes": true,
|
13
|
+
"operationResultTask": true,
|
14
|
+
"enumNameSuffix": "",
|
15
|
+
"enumValueSuffix": ""
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
source $(dirname "$0")/../common.sh
|
4
|
+
|
5
|
+
cd out/$targetId
|
6
|
+
|
7
|
+
# install dotnet
|
8
|
+
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
|
9
|
+
chmod +x dotnet-install.sh
|
10
|
+
./dotnet-install.sh --channel 8.0 --install-dir "$HOME/.dotnet"
|
11
|
+
export PATH="$HOME/.dotnet:$PATH"
|
12
|
+
|
13
|
+
# pack
|
14
|
+
dotnet restore
|
15
|
+
dotnet build -c Release
|
16
|
+
dotnet pack -c Release -p:Version=$version -p:IsPackable=true
|
17
|
+
|
18
|
+
# publish
|
19
|
+
dotnet nuget push "src/**/bin/Release/*.nupkg" --source $sourceUrl -k ${apiKey:-$CI_JOB_TOKEN}
|
20
|
+
|
21
|
+
cd ../..
|
@@ -0,0 +1,198 @@
|
|
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
|
+
{{#useNewtonsoft}}
|
10
|
+
using Newtonsoft.Json;
|
11
|
+
{{/useNewtonsoft}}
|
12
|
+
{{^useNewtonsoft}}
|
13
|
+
using System.Text.Json;
|
14
|
+
{{/useNewtonsoft}}
|
15
|
+
{{#models}}
|
16
|
+
{{#model}}
|
17
|
+
{{#discriminator}}
|
18
|
+
using JsonSubTypes;
|
19
|
+
{{#useSwashbuckle}}
|
20
|
+
using Swashbuckle.AspNetCore.Annotations;
|
21
|
+
{{/useSwashbuckle}}
|
22
|
+
{{/discriminator}}
|
23
|
+
{{/model}}
|
24
|
+
{{/models}}
|
25
|
+
using {{packageName}}.Converters;
|
26
|
+
|
27
|
+
{{#models}}
|
28
|
+
{{#model}}
|
29
|
+
namespace {{modelPackage}}
|
30
|
+
{ {{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
|
31
|
+
/// <summary>
|
32
|
+
/// {{description}}
|
33
|
+
/// </summary>
|
34
|
+
[DataContract]
|
35
|
+
{{#discriminator}}
|
36
|
+
{{#useNewtonsoft}}
|
37
|
+
{{#mappedModels.size}}
|
38
|
+
[JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")]
|
39
|
+
{{/mappedModels.size}}
|
40
|
+
{{/useNewtonsoft}}
|
41
|
+
{{#useSwashbuckle}}
|
42
|
+
[SwaggerDiscriminator("{{{discriminatorName}}}")]
|
43
|
+
{{/useSwashbuckle}}
|
44
|
+
{{#mappedModels}}
|
45
|
+
[JsonSubtypes.KnownSubType(typeof({{{modelName}}}), "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")]
|
46
|
+
{{#useSwashbuckle}}
|
47
|
+
[SwaggerSubType(typeof({{{modelName}}}), DiscriminatorValue = "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")]
|
48
|
+
{{/useSwashbuckle}}
|
49
|
+
{{/mappedModels}}
|
50
|
+
{{/discriminator}}
|
51
|
+
public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} {{#parent}}: {{{.}}}{{^pocoModels}}, {{/pocoModels}}{{/parent}}{{^pocoModels}}{{^parent}}: {{/parent}}IEquatable<{{classname}}>{{/pocoModels}}
|
52
|
+
{
|
53
|
+
{{#vars}}
|
54
|
+
{{#items.isEnum}}
|
55
|
+
{{#items}}
|
56
|
+
{{^complexType}}
|
57
|
+
{{>enumClass}}
|
58
|
+
{{/complexType}}
|
59
|
+
{{/items}}
|
60
|
+
{{/items.isEnum}}
|
61
|
+
{{#isEnum}}
|
62
|
+
{{^complexType}}
|
63
|
+
{{>enumClass}}
|
64
|
+
{{/complexType}}
|
65
|
+
{{/isEnum}}
|
66
|
+
/// <summary>
|
67
|
+
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
68
|
+
/// </summary>{{#description}}
|
69
|
+
/// <value>{{.}}</value>{{/description}}{{#example}}
|
70
|
+
/* <example>{{.}}</example> */{{/example}}{{#required}}
|
71
|
+
[Required]{{/required}}{{#pattern}}
|
72
|
+
[RegularExpression("{{{.}}}")]{{/pattern}}{{#minLength}}{{#maxLength}}
|
73
|
+
[StringLength({{maxLength}}, MinimumLength={{minLength}})]{{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}}
|
74
|
+
[MinLength({{minLength}})]{{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}}
|
75
|
+
[MaxLength({{.}})]{{/maxLength}}{{/minLength}}{{#minimum}}{{#maximum}}
|
76
|
+
[Range({{minimum}}, {{maximum}})]{{/maximum}}{{/minimum}}
|
77
|
+
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}true{{/vendorExtensions.x-is-value-type}}{{^vendorExtensions.x-is-value-type}}false{{/vendorExtensions.x-is-value-type}}{{/isNullable}})]
|
78
|
+
{{#isEnum}}
|
79
|
+
public {{{datatypeWithEnum}}}{{#isNullable}}{{^required}}?{{/required}}{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
80
|
+
{{/isEnum}}
|
81
|
+
{{^isEnum}}
|
82
|
+
public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
83
|
+
{{/isEnum}}
|
84
|
+
{{^-last}}
|
85
|
+
|
86
|
+
{{/-last}}
|
87
|
+
{{/vars}}
|
88
|
+
|
89
|
+
{{^pocoModels}}
|
90
|
+
/// <summary>
|
91
|
+
/// Returns the string presentation of the object
|
92
|
+
/// </summary>
|
93
|
+
/// <returns>String presentation of the object</returns>
|
94
|
+
public override string ToString()
|
95
|
+
{
|
96
|
+
var sb = new StringBuilder();
|
97
|
+
sb.Append("class {{classname}} {\n");
|
98
|
+
{{#vars}}
|
99
|
+
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
|
100
|
+
{{/vars}}
|
101
|
+
sb.Append("}\n");
|
102
|
+
return sb.ToString();
|
103
|
+
}
|
104
|
+
|
105
|
+
/// <summary>
|
106
|
+
/// Returns the JSON string presentation of the object
|
107
|
+
/// </summary>
|
108
|
+
/// <returns>JSON string presentation of the object</returns>
|
109
|
+
public {{#parent}}{{^isMap}}{{^isArray}}new {{/isArray}}{{/isMap}}{{/parent}}string ToJson()
|
110
|
+
{
|
111
|
+
{{#useNewtonsoft}}
|
112
|
+
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
113
|
+
{{/useNewtonsoft}}
|
114
|
+
{{^useNewtonsoft}}
|
115
|
+
var options = new JsonSerializerOptions
|
116
|
+
{
|
117
|
+
WriteIndented = true
|
118
|
+
};
|
119
|
+
|
120
|
+
return JsonSerializer.Serialize(this, options);
|
121
|
+
{{/useNewtonsoft}}
|
122
|
+
}
|
123
|
+
|
124
|
+
/// <summary>
|
125
|
+
/// Returns true if objects are equal
|
126
|
+
/// </summary>
|
127
|
+
/// <param name="obj">Object to be compared</param>
|
128
|
+
/// <returns>Boolean</returns>
|
129
|
+
public override bool Equals(object obj)
|
130
|
+
{
|
131
|
+
if (obj is null) return false;
|
132
|
+
if (ReferenceEquals(this, obj)) return true;
|
133
|
+
return obj.GetType() == GetType() && Equals(({{classname}})obj);
|
134
|
+
}
|
135
|
+
|
136
|
+
/// <summary>
|
137
|
+
/// Returns true if {{classname}} instances are equal
|
138
|
+
/// </summary>
|
139
|
+
/// <param name="other">Instance of {{classname}} to be compared</param>
|
140
|
+
/// <returns>Boolean</returns>
|
141
|
+
public bool Equals({{classname}} other)
|
142
|
+
{
|
143
|
+
if (other is null) return false;
|
144
|
+
if (ReferenceEquals(this, other)) return true;
|
145
|
+
|
146
|
+
return {{#vars}}{{^isContainer}}
|
147
|
+
(
|
148
|
+
{{name}} == other.{{name}} ||
|
149
|
+
{{^vendorExtensions.x-is-value-type}}{{name}} != null &&{{/vendorExtensions.x-is-value-type}}
|
150
|
+
{{name}}.Equals(other.{{name}})
|
151
|
+
){{^-last}} && {{/-last}}{{/isContainer}}{{#isContainer}}
|
152
|
+
(
|
153
|
+
{{name}} == other.{{name}} ||
|
154
|
+
{{^vendorExtensions.x-is-value-type}}{{name}} != null &&
|
155
|
+
other.{{name}} != null &&
|
156
|
+
{{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(other.{{name}})
|
157
|
+
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
|
158
|
+
}
|
159
|
+
|
160
|
+
/// <summary>
|
161
|
+
/// Gets the hash code
|
162
|
+
/// </summary>
|
163
|
+
/// <returns>Hash code</returns>
|
164
|
+
public override int GetHashCode()
|
165
|
+
{
|
166
|
+
unchecked // Overflow is fine, just wrap
|
167
|
+
{
|
168
|
+
var hashCode = 41;
|
169
|
+
// Suitable nullity checks etc, of course :)
|
170
|
+
{{#vars}}
|
171
|
+
{{^vendorExtensions.x-is-value-type}}if ({{name}} != null){{/vendorExtensions.x-is-value-type}}
|
172
|
+
hashCode = hashCode * 59 + {{name}}.GetHashCode();
|
173
|
+
{{/vars}}
|
174
|
+
return hashCode;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
#region Operators
|
179
|
+
#pragma warning disable 1591
|
180
|
+
|
181
|
+
public static bool operator ==({{classname}} left, {{classname}} right)
|
182
|
+
{
|
183
|
+
return Equals(left, right);
|
184
|
+
}
|
185
|
+
|
186
|
+
public static bool operator !=({{classname}} left, {{classname}} right)
|
187
|
+
{
|
188
|
+
return !Equals(left, right);
|
189
|
+
}
|
190
|
+
|
191
|
+
#pragma warning restore 1591
|
192
|
+
#endregion Operators
|
193
|
+
{{/pocoModels}}
|
194
|
+
}
|
195
|
+
{{/isEnum}}
|
196
|
+
{{/model}}
|
197
|
+
{{/models}}
|
198
|
+
}
|
@@ -18,7 +18,7 @@ import { {{ classname }} } from '{{ filename }}';
|
|
18
18
|
{{/imports}}
|
19
19
|
|
20
20
|
{{#operations}}
|
21
|
-
{{#operation}}{{#allParams.0}}export interface {{operationIdCamelCase}}Context { params: { {{#allParams}}{{^isBodyParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/isBodyParam}}{{/allParams}} }{{#bodyParam}}, body: {{{dataType}}}{{/bodyParam}} };{{/allParams.0}}
|
21
|
+
{{#operation}}{{#allParams.0}}export interface {{operationIdCamelCase}}Context { params: { {{#allParams}}{{^isBodyParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/isBodyParam}}{{/allParams}} }{{#bodyParam}}, body{{^required}}?{{/required}}: {{{dataType}}}{{/bodyParam}} };{{/allParams.0}}
|
22
22
|
{{/operation}}
|
23
23
|
|
24
24
|
{{#description}}
|