@team-supercharge/oasg 16.7.0 → 16.7.1-temp-feat-swift-openapi-generator-4739d9f5

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
@@ -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
+ | `swift-openapi-generator` |🆕 |
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
+ #### `swift-openapi-generator`
706
+
707
+ ```json
708
+ {
709
+ "id": "client-ios",
710
+ "type": "swift-openapi-generator",
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
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
+ "swift-openapi-generator": { 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' },
package/config.schema.yml CHANGED
@@ -312,6 +312,20 @@ targets:
312
312
  - repository
313
313
  - interfaceType
314
314
 
315
+ SwiftOpenAPIGenerator:
316
+ allOf:
317
+ - $ref: '#/targets/Base'
318
+ - properties:
319
+ type:
320
+ pattern: "^swift-openapi-generator$"
321
+ packageName:
322
+ type: string
323
+ repositoryUrl:
324
+ type: string
325
+ required:
326
+ - packageName
327
+ - repositoryUrl
328
+
315
329
  Python:
316
330
  allOf:
317
331
  - $ref: '#/targets/Base'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "16.7.0",
3
+ "version": "16.7.1-temp-feat-swift-openapi-generator-4739d9f5",
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",
@@ -51,7 +51,7 @@ export abstract class {{classname}} {
51
51
  //// @{{httpMethod}}('{{path}}'){{#isMultipart}}
52
52
  @UseInterceptors(FileInterceptor({{#formParams}}{{#isFile}}'{{paramName}}'{{/isFile}}{{/formParams}})){{/isMultipart}}
53
53
  @HttpCode({{#responses.0}}{{code}}{{/responses.0}})
54
- private _{{nickname}}(@Request() req: unknown, @Response() res: unknown{{#allParams}}{{^isBodyParam}}, {{#isQueryParam}}@Query({{/isQueryParam}}{{#isPathParam}}@Param({{/isPathParam}}{{#isHeaderParam}}@Headers({{/isHeaderParam}}{{#isFormParam}}{{^isFile}}@Body({{/isFile}}{{#isFile}}@UploadedFile({{/isFile}}{{/isFormParam}}'{{paramName}}'{{#required}}{{#isHeaderParam}}{{/isHeaderParam}}{{^isHeaderParam}}, RequiredPipe{{/isHeaderParam}}{{/required}}{{#isArray}}, new ApiParseArrayPipe({ optional: true{{#items}}{{#isNumeric}}, items: Number{{/isNumeric}}{{#isBoolean}}, items: Boolean{{/isBoolean}}{{/items}} }){{/isArray}}{{#isNumber}}, OptionalParseFloatPipe{{/isNumber}}{{#isFloat}}, OptionalParseFloatPipe{{/isFloat}}{{#isDouble}}, OptionalParseFloatPipe{{/isDouble}}{{#isInteger}}, OptionalParseIntPipe{{/isInteger}}{{#isLong}}, OptionalParseIntPipe{{/isLong}}{{#isBoolean}}, OptionalParseBoolPipe{{/isBoolean}}{{#allowableValues}}{{^enumVars.empty}}, new OptionalParseEnumPipe({{{dataType}}}){{/enumVars.empty}}{{/allowableValues}}) {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{/isBodyParam}}{{/allParams}}{{#bodyParam}}, @Body(new ApiValidationPipe({ whitelist: true, forbidNonWhitelisted: true })) requestBody{{^required}}?{{/required}}: {{{dataType}}}{{/bodyParam}}): Promise<{{#returnType}}{{#isResponseFile}}StreamableFile{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
54
+ private _{{nickname}}(@Request() req: unknown, @Response({ passthrough: true }) res: unknown{{#allParams}}{{^isBodyParam}}, {{#isQueryParam}}@Query({{/isQueryParam}}{{#isPathParam}}@Param({{/isPathParam}}{{#isHeaderParam}}@Headers({{/isHeaderParam}}{{#isFormParam}}{{^isFile}}@Body({{/isFile}}{{#isFile}}@UploadedFile({{/isFile}}{{/isFormParam}}'{{paramName}}'{{#required}}{{#isHeaderParam}}{{/isHeaderParam}}{{^isHeaderParam}}, RequiredPipe{{/isHeaderParam}}{{/required}}{{#isArray}}, new ApiParseArrayPipe({ optional: true{{#items}}{{#isNumeric}}, items: Number{{/isNumeric}}{{#isBoolean}}, items: Boolean{{/isBoolean}}{{/items}} }){{/isArray}}{{#isNumber}}, OptionalParseFloatPipe{{/isNumber}}{{#isFloat}}, OptionalParseFloatPipe{{/isFloat}}{{#isDouble}}, OptionalParseFloatPipe{{/isDouble}}{{#isInteger}}, OptionalParseIntPipe{{/isInteger}}{{#isLong}}, OptionalParseIntPipe{{/isLong}}{{#isBoolean}}, OptionalParseBoolPipe{{/isBoolean}}{{#allowableValues}}{{^enumVars.empty}}, new OptionalParseEnumPipe({{{dataType}}}){{/enumVars.empty}}{{/allowableValues}}) {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{/isBodyParam}}{{/allParams}}{{#bodyParam}}, @Body(new ApiValidationPipe({ whitelist: true, forbidNonWhitelisted: true })) requestBody{{^required}}?{{/required}}: {{{dataType}}}{{/bodyParam}}): Promise<{{#returnType}}{{#isResponseFile}}StreamableFile{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
55
55
  return this.{{nickname}}({{#allParams.0}}{ params: { {{#allParams}}{{^isBodyParam}}{{^-first}}, {{/-first}}{{paramName}}{{/isBodyParam}}{{/allParams}} }{{#bodyParam}}, body: requestBody{{/bodyParam}} }, {{/allParams.0}}req, res);
56
56
  }
57
57
 
@@ -0,0 +1,26 @@
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
+ ],
13
+ dependencies: [
14
+ .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
15
+ .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
16
+ ],
17
+ targets: [
18
+ .target(
19
+ name: "__PROJECT_NAME__",
20
+ dependencies: [
21
+ .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
22
+ .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
23
+ ]
24
+ )
25
+ ]
26
+ )
@@ -0,0 +1,21 @@
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
+ # Variables
10
+ OPENAPI_GENERATOR_CONFIG_PATH=openapi-generator-config.yaml
11
+
12
+ # Generate the swift client
13
+ swift-openapi-generator \
14
+ generate \
15
+ --config "$OPENAPI_GENERATOR_CONFIG_PATH" \
16
+ --output-directory "out/$targetId/Sources/$projectName" \
17
+ "$openApiFile"
18
+
19
+ # Copy Package.swift file
20
+ cp Package.swift out/$targetId
21
+ sed -i '' "s/__PROJECT_NAME__/$projectName/" out/$targetId/Package.swift
@@ -0,0 +1,5 @@
1
+ generate:
2
+ - types
3
+ - client
4
+ accessModifier: public
5
+ namingStrategy: idiomatic
@@ -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 ../..