@team-supercharge/oasg 14.1.0-fix-android-publishing-group-998336b0.0 → 14.1.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
@@ -454,6 +454,20 @@ Common target parameters
454
454
  | packageName | Name of the generated NPM package | Y | - |
455
455
  | repository | URL of the NPM package registry | Y | - |
456
456
 
457
+ ##### Known issue: breaking dependencies
458
+
459
+ The Angular target has a known issue related to dependency versioning. The generated Angular project's `package.json` currently defines multiple dependencies with flexible versions (e.g., using `^` or `~` in version constraints). This flexibility allows newer versions of dependencies (not to mention the transitive dependencies), to be pulled in, which can occasionally lead to breaking changes.
460
+
461
+ A notable instance of this issue occurred with **Angular version 12**, which introduced changes that broke the build of generated projects. To address this specific case, we implemented a **temporary fix** in the `targets/angular/generate.sh` script. This script now manually installs problematic dependencies with fixed, validated versions.
462
+
463
+ ###### Long-Term Solution
464
+
465
+ We are actively discussing a long-term solution to this issue. Potential approaches include implementing dependency version locking mechanisms (`package-lock.json`) per Angular versions.
466
+
467
+ The temporary fix may not cover all future breaking changes from other dependencies. Projects using different versions of Angular may encounter issues if the fix does not align with their specific requirements.
468
+
469
+ We welcome feedback and contributions to help address this issue.
470
+
457
471
  #### `react`
458
472
 
459
473
  ```json
@@ -683,6 +697,47 @@ TBD
683
697
 
684
698
  Publishing the PyPI packages is done with Twine. For authentication againts the PiPI repository you need to set the `TWINE_USERNAME` and `TWINE_PASSWORD` environment variables.
685
699
 
700
+
701
+ #### `python-fastapi`
702
+
703
+ ```json
704
+ {
705
+ "id": "server-python",
706
+ "type": "python-fastapi",
707
+ "source": "source-merged",
708
+ "packageName": "oasg_example",
709
+ "repositoryUrl": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/pypi"
710
+ }
711
+ ```
712
+
713
+ |Parameter| Description| Required | Default |
714
+ |-|-|-|-|
715
+ | packageName | Package nem for the project (convention: snake_case) | Y | - |
716
+ | repositoryUrl | URL of the PyPI repository | Y | - |
717
+
718
+ Building the distribution package requires Flit.
719
+ Publishing the PyPI packages is done with Twine. For authentication againts the PiPI repository you need to set the `TWINE_USERNAME` and `TWINE_PASSWORD` environment variables.
720
+
721
+ #### `python-fastapi-raw-request`
722
+
723
+ ```json
724
+ {
725
+ "id": "server-python",
726
+ "type": "python-fastapi-raw-request",
727
+ "source": "source-merged",
728
+ "packageName": "oasg_example",
729
+ "repositoryUrl": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/pypi"
730
+ }
731
+ ```
732
+
733
+ |Parameter| Description| Required | Default |
734
+ |-|-|-|-|
735
+ | packageName | Package nem for the project (convention: snake_case) | Y | - |
736
+ | repositoryUrl | URL of the PyPI repository | Y | - |
737
+
738
+ Building the distribution package requires Flit.
739
+ Publishing the PyPI packages is done with Twine. For authentication againts the PiPI repository you need to set the `TWINE_USERNAME` and `TWINE_PASSWORD` environment variables.
740
+
686
741
  #### `contract-testing`
687
742
 
688
743
  ```json
@@ -784,6 +839,41 @@ describe('Auth', function () {
784
839
  - array of enums in query/header/path/form parameters are not validated (stay as string)
785
840
  - no multidimensional array validation in DTOs
786
841
 
842
+ **Validation availability:**
843
+ <br> _List is not comprehensive, missing items are definitely not currently supported_
844
+
845
+ | Validation | DTO | Query | Header | Path |
846
+ | ---------------------------------------- | --- | ----- | ------ | ---- |
847
+ | **Common** | | | | |
848
+ | IsOptional _(!required)_ | ✅ | ✅ | ✅ | ✅ |
849
+ | IsDefined _(required)_ | ✅ | ✅ | ✅ | ✅ |
850
+ | **Types** | | | | |
851
+ | IsBoolean | ✅ | ✅ | ✅ | ✅ |
852
+ | IsDate _(isDate, isDateTime)_ | ❌ | ❌ | ❌ | ❌ |
853
+ | IsString | ✅ | ✅ | ✅ | ✅ |
854
+ | IsNumber _(isNumber, isFloat, isDouble)_ | ✅ | ✅ | ✅ | ✅ |
855
+ | IsInt _(isInt, isLong)_ | ✅ | ✅ | ✅ | ✅ |
856
+ | IsInt _(isShort, isUnboundedInteger)_ | ❌ | ❌ | ❌ | ❌ |
857
+ | IsEnum | ✅ | ✅ | ✅ | ✅ |
858
+ | IsArray | ✅ | ✅ | ✅ | ✅ |
859
+ | **String** | | | | |
860
+ | MinLength | ❌ | ❌ | ❌ | ❌ |
861
+ | MaxLength | ❌ | ❌ | ❌ | ❌ |
862
+ | Matches _(pattern)_ | ✅ | ✅ | ✅ | ✅ |
863
+ | IsUUID _(isUuid)_ | ❌ | ❌ | ❌ | ❌ |
864
+ | IsDataURI _(isUri)_ | ❌ | ❌ | ❌ | ❌ |
865
+ | IsEmail _(isEmail)_ | ❌ | ❌ | ❌ | ❌ |
866
+ | **Number** | | | | |
867
+ | Min | ❌ | ❌ | ❌ | ❌ |
868
+ | Max | ❌ | ❌ | ❌ | ❌ |
869
+ | IsDivisibleBy _(multipleOf)_ | ❌ | ❌ | ❌ | ❌ |
870
+ | IsDecimal _(isDecimal)_ | ❌ | ❌ | ❌ | ❌ |
871
+ | **Array** | | | | |
872
+ | multidimensional array | ❌ | ❌ | ❌ | ❌ |
873
+ | enum arrays | ✅ | ❌ | ❌ | ❌ |
874
+
875
+
876
+
787
877
  #### `openapi`
788
878
 
789
879
  ```json
package/bin/oasg CHANGED
@@ -34,24 +34,26 @@ const PROXY_PORT = '9999';
34
34
 
35
35
  const DEFAULT_GENERATOR_MAPPING = {
36
36
  // client targets
37
- "android": { version: '7.0.1', generator: 'kotlin' },
38
- "angular": { version: '7.0.1', generator: 'typescript-angular' },
39
- "feign": { version: '7.0.1', generator: 'spring' },
40
- "feign-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
41
- "flutter": { version: '7.0.1', generator: 'dart-dio' },
42
- "ios": { version: '7.0.1', generator: 'swift5' },
43
- "kmp": { version: '7.8.0', generator: 'kotlin' },
44
- "python": { version: '7.0.1', generator: 'python' },
45
- "react": { version: '7.0.1', generator: 'typescript-fetch' },
37
+ "android": { version: '7.0.1', generator: 'kotlin' },
38
+ "angular": { version: '7.0.1', generator: 'typescript-angular' },
39
+ "feign": { version: '7.0.1', generator: 'spring' },
40
+ "feign-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
41
+ "flutter": { version: '7.0.1', generator: 'dart-dio' },
42
+ "ios": { version: '7.0.1', generator: 'swift5' },
43
+ "kmp": { version: '7.8.0', generator: 'kotlin' },
44
+ "python": { version: '7.0.1', generator: 'python' },
45
+ "react": { version: '7.0.1', generator: 'typescript-fetch' },
46
46
  // server targets
47
- "nestjs": { version: '7.0.1', generator: 'typescript-angular' },
48
- "spring": { version: '7.0.1', generator: 'spring' },
49
- "spring-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
50
- "dotnet": { version: '7.8.0', generator: 'csharp-functions' },
47
+ "nestjs": { version: '7.0.1', generator: 'typescript-angular' },
48
+ "spring": { version: '7.0.1', generator: 'spring' },
49
+ "spring-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
50
+ "python-fastapi": { version: '7.8.0', generator: 'python-fastapi' },
51
+ "python-fastapi-raw-request": { version: '7.0.1', generator: 'python-fastapi' },
52
+ "dotnet": { version: '7.8.0', generator: 'csharp-functions' },
51
53
  // misc targets
52
- "contract-testing": { version: '4.3.1', generator: 'typescript-node' },
53
- "openapi": { version: undefined, generator: undefined },
54
- "stubby": { version: '4.3.1', generator: 'stubby' },
54
+ "contract-testing": { version: '4.3.1', generator: 'typescript-node' },
55
+ "openapi": { version: undefined, generator: undefined },
56
+ "stubby": { version: '4.3.1', generator: 'stubby' },
55
57
  };
56
58
  const DEFAULT_KTLINT_VERSION = '1.0.0';
57
59
  const BIN_FOLDER = 'out/.bin';
package/config.schema.yml CHANGED
@@ -20,6 +20,8 @@ properties:
20
20
  - $ref: '#/targets/Android'
21
21
  - $ref: '#/targets/ios'
22
22
  - $ref: '#/targets/Python'
23
+ - $ref: '#/targets/PythonFastApi'
24
+ - $ref: '#/targets/PythonFastApiRawRequest'
23
25
  - $ref: '#/targets/ContractTesting'
24
26
  - $ref: '#/targets/NestJS'
25
27
  - $ref: '#/targets/OpenAPI'
@@ -297,6 +299,34 @@ targets:
297
299
  - packageName
298
300
  - repositoryUrl
299
301
 
302
+ PythonFastApi:
303
+ allOf:
304
+ - $ref: '#/targets/Base'
305
+ - properties:
306
+ type:
307
+ pattern: "^python-fastapi$"
308
+ packageName:
309
+ type: string
310
+ repositoryUrl:
311
+ type: string
312
+ required:
313
+ - packageName
314
+ - repositoryUrl
315
+
316
+ PythonFastApiRawRequest:
317
+ allOf:
318
+ - $ref: '#/targets/Base'
319
+ - properties:
320
+ type:
321
+ pattern: "^python-fastapi-raw-request$"
322
+ packageName:
323
+ type: string
324
+ repositoryUrl:
325
+ type: string
326
+ required:
327
+ - packageName
328
+ - repositoryUrl
329
+
300
330
  ContractTesting:
301
331
  allOf:
302
332
  - $ref: '#/targets/Base'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "14.1.0-fix-android-publishing-group-998336b0.0",
3
+ "version": "14.1.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,5 +15,9 @@ java -jar $binary generate \
15
15
 
16
16
  cd out/$targetId
17
17
  npm install
18
+ # This is a workaround for an issue with the angular generator. Root cause is the missing package-lock.json: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/typescript-angular
19
+ # some of the transitive dependency has @types/node@": "*" in their package.json
20
+ # use "npm explain @types/node" in the generated folder (./out/$TARGET) to get more info
21
+ npm install --save-dev @types/node@20.15.0
18
22
  npm run build
19
23
  cd ../..
@@ -2,9 +2,12 @@
2
2
 
3
3
  source $(dirname "$0")/../common.sh
4
4
 
5
- # change npm pre-release syntax (with - after semver) to python local syntax (with + after semver)
6
- version=$(echo $version | sed 's/-/\+/')
7
- echo "[NOTE] version updated to: ${version}"
5
+ # if the version contains a `-` character, then use PEP 440 beta version syntax
6
+ # example: 1.0.0-beta.1 -> 1.0.0b0+beta.1
7
+ if [[ $version == *"-"* ]]; then
8
+ version=$(echo $version | sed 's/-/b0+/')
9
+ echo "[NOTE] version updated to: ${version}"
10
+ fi
8
11
 
9
12
  rm -rf out/$targetId
10
13
  mkdir -p out/$targetId
@@ -0,0 +1,32 @@
1
+ #/bin/bash
2
+
3
+ source $(dirname "$0")/../common.sh
4
+
5
+ # if the version contains a `-` character, then use PEP 440 beta version syntax
6
+ # example: 1.0.0-beta.1 -> 1.0.0b0+beta.1
7
+ if [[ $version == *"-"* ]]; then
8
+ version=$(echo $version | sed 's/-/b0+/')
9
+ echo "[NOTE] version updated to: ${version}"
10
+ fi
11
+
12
+ rm -rf out/$targetId
13
+ mkdir -p out/$targetId
14
+
15
+ java -jar $binary generate \
16
+ -g $generatorId \
17
+ -i $openApiFile \
18
+ -t $templateDir \
19
+ -o out/$targetId \
20
+ -c $(dirname "$0")/generator-config.json \
21
+ -p "packageVersion=$version,packageName=$packageName" $generatorCustomArgs
22
+
23
+ cd out/$targetId
24
+
25
+ touch "src/$packageName/__init__.py"
26
+ python3 -m venv venv
27
+ source venv/bin/activate
28
+ pip install --upgrade pip
29
+ pip install flit==3.9.0
30
+ flit build --no-use-vcs
31
+
32
+ cd ../../
@@ -0,0 +1,7 @@
1
+ {
2
+ "inlineSchemaOptions": {
3
+ "ARRAY_ITEM_SUFFIX": "",
4
+ "MAP_ITEM_SUFFIX": "",
5
+ "SKIP_SCHEMA_REUSE": "true"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ #/bin/bash
2
+
3
+ source $(dirname "$0")/../common.sh
4
+
5
+ cd out/$targetId
6
+ source venv/bin/activate
7
+ pip install importlib_metadata==7.2.1 twine==4.0.2
8
+ python3 -m twine upload --repository-url $repositoryUrl dist/*
9
+ cd ../..
@@ -0,0 +1,32 @@
1
+ #/bin/bash
2
+
3
+ source $(dirname "$0")/../common.sh
4
+
5
+ # if the version contains a `-` character, then use PEP 440 beta version syntax
6
+ # example: 1.0.0-beta.1 -> 1.0.0b0+beta.1
7
+ if [[ $version == *"-"* ]]; then
8
+ version=$(echo $version | sed 's/-/b0+/')
9
+ echo "[NOTE] version updated to: ${version}"
10
+ fi
11
+
12
+ rm -rf out/$targetId
13
+ mkdir -p out/$targetId
14
+
15
+ java -jar $binary generate \
16
+ -g $generatorId \
17
+ -i $openApiFile \
18
+ -t $templateDir \
19
+ -o out/$targetId \
20
+ -c $(dirname "$0")/generator-config.json \
21
+ -p "packageVersion=$version,packageName=$packageName" $generatorCustomArgs
22
+
23
+ cd out/$targetId
24
+
25
+ touch "src/$packageName/__init__.py"
26
+ python3 -m venv venv
27
+ source venv/bin/activate
28
+ pip install --upgrade pip
29
+ pip install flit==3.9.0
30
+ flit build --no-use-vcs
31
+
32
+ cd ../../
@@ -0,0 +1,7 @@
1
+ {
2
+ "inlineSchemaOptions": {
3
+ "ARRAY_ITEM_SUFFIX": "",
4
+ "MAP_ITEM_SUFFIX": "",
5
+ "SKIP_SCHEMA_REUSE": "true"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ #/bin/bash
2
+
3
+ source $(dirname "$0")/../common.sh
4
+
5
+ cd out/$targetId
6
+ source venv/bin/activate
7
+ pip install importlib_metadata==7.2.1 twine==4.0.2
8
+ python3 -m twine upload --repository-url $repositoryUrl dist/*
9
+ cd ../..
@@ -0,0 +1,43 @@
1
+ # OpenAPI generated FastAPI server
2
+
3
+ This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
4
+
5
+ - API version: {{appVersion}}
6
+ {{^hideGenerationTimestamp}}
7
+ - Build date: {{generatedDate}}
8
+ {{/hideGenerationTimestamp}}
9
+ - Build package: {{generatorClass}}
10
+
11
+ ## Requirements.
12
+
13
+ Python >= {{{generatorLanguageVersion}}}
14
+
15
+ ## Installation & Usage
16
+
17
+ To run the server, please execute the following from the root directory:
18
+
19
+ ```bash
20
+ pip3 install -r requirements.txt
21
+ pip3 install uvicorn
22
+ uvicorn --app-dir src {{packageName}}.main:app --host 0.0.0.0 --port {{serverPort}}
23
+ ```
24
+
25
+ and open your browser at `http://localhost:{{serverPort}}/docs/` to see the docs.
26
+
27
+ ## Running with Docker
28
+
29
+ To run the server on a Docker container, please execute the following from the root directory:
30
+
31
+ ```bash
32
+ docker-compose up --build
33
+ ```
34
+
35
+ ## Tests
36
+
37
+ To run the tests:
38
+
39
+ ```bash
40
+ pip3 install pytest
41
+ pip3 install httpx
42
+ PYTHONPATH=src pytest tests
43
+ ```
@@ -0,0 +1,62 @@
1
+ # coding: utf-8
2
+
3
+ from typing import Dict, List # noqa: F401
4
+ import importlib
5
+ import pkgutil
6
+
7
+ from {{apiPackage}}.{{classFilename}}_{{baseSuffix}} import Base{{classname}}
8
+
9
+ from fastapi import ( # noqa: F401
10
+ APIRouter,
11
+ Body,
12
+ Cookie,
13
+ Depends,
14
+ Form,
15
+ Header,
16
+ Path,
17
+ Query,
18
+ Request,
19
+ Response,
20
+ Security,
21
+ status,
22
+ )
23
+
24
+ from {{modelPackage}}.extra_models import TokenModel # noqa: F401
25
+ {{#imports}}
26
+ {{import}}
27
+ {{/imports}}
28
+
29
+ router = APIRouter()
30
+
31
+ {{#operations}}
32
+ {{#operation}}
33
+ @router.{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}(
34
+ "{{path}}",
35
+ responses={
36
+ {{#responses}}
37
+ {{code}}: {{=<% %>=}}{<%#dataType%>"model": <%dataType%>, "description": "<%message%>"<%/dataType%><%^dataType%>"description": "<%message%>"<%/dataType%>}<%={{ }}=%>,
38
+ {{/responses}}
39
+ },
40
+ tags=[{{#tags}}"{{name}}"{{^-last}},{{/-last}}{{/tags}}],
41
+ {{#summary}}
42
+ summary="{{.}}",
43
+ {{/summary}}
44
+ {{#description}}
45
+ description = "{{.}}",
46
+ {{/description}}
47
+ response_model_by_alias=True,
48
+ )
49
+ async def {{operationId}}(
50
+ request: Request,
51
+ {{#allParams}}
52
+ {{>endpoint_argument_definition}},
53
+ {{/allParams}}
54
+ ) -> Response: # -> {{returnType}}{{^returnType}}None{{/returnType}}
55
+ {{#notes}}"""{{.}}"""
56
+ return await Base{{classname}}.subclasses[0]().{{operationId}}(request{{#allParams}}, {{>impl_argument}}{{/allParams}}){{/notes}}{{^notes}}...{{/notes}}
57
+ {{^-last}}
58
+
59
+
60
+ {{/-last}}
61
+ {{/operation}}
62
+ {{/operations}}
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+
3
+ from typing import ClassVar, Dict, List, Tuple # noqa: F401
4
+ from fastapi import Request, Response
5
+
6
+ {{#imports}}
7
+ {{import}}
8
+ {{/imports}}
9
+
10
+ class Base{{classname}}:
11
+ subclasses: ClassVar[Tuple] = ()
12
+
13
+ def __init_subclass__(cls, **kwargs):
14
+ super().__init_subclass__(**kwargs)
15
+ Base{{classname}}.subclasses = Base{{classname}}.subclasses + (cls,)
16
+
17
+ {{#operations}}
18
+ {{#operation}}
19
+ async def {{operationId}}(
20
+ self,
21
+ request: Request,
22
+ {{#allParams}}
23
+ {{>impl_argument_definition}},
24
+ {{/allParams}}
25
+ ) -> Response: # -> {{returnType}}{{^returnType}}None{{/returnType}}
26
+ {{#notes}}"""{{.}}"""
27
+ ...{{/notes}}{{^notes}}...{{/notes}}
28
+ {{^-last}}
29
+
30
+ {{/-last}}
31
+ {{/operation}}
32
+ {{/operations}}
@@ -0,0 +1 @@
1
+ {{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}({{&defaultValue}}{{^defaultValue}}{{#isPathParam}}...{{/isPathParam}}{{^isPathParam}}None{{/isPathParam}}{{/defaultValue}}, description="{{description}}"{{#isQueryParam}}, alias="{{baseName}}"{{/isQueryParam}}{{#isLong}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isLong}}{{#isInteger}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isInteger}}{{#pattern}}, regex=r"{{.}}"{{/pattern}}{{#minLength}}, min_length={{.}}{{/minLength}}{{#maxLength}}, max_length={{.}}{{/maxLength}})
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "{{packageName}}"
3
+ version = "{{packageVersion}}"
4
+ description = "{{appDescription}}"
5
+
6
+ [build-system]
7
+ requires = ["setuptools", "wheel"]
8
+ build-backend = "setuptools.build_meta"
9
+
10
+ [tool.black]
11
+ line-length = 88
12
+ exclude = '''
13
+ (
14
+ /(
15
+ \.eggs # exclude a few common directories in the
16
+ | \.git # root of the project
17
+ | \.hg
18
+ | \.mypy_cache
19
+ | \.tox
20
+ | \.venv
21
+ | _build
22
+ | buck-out
23
+ | build
24
+ | dist
25
+ )/
26
+ )
27
+ '''
28
+
29
+ [tool.isort]
30
+ profile = "black"
31
+ skip = [
32
+ '.eggs', '.git', '.hg', '.mypy_cache', '.nox', '.pants.d', '.tox',
33
+ '.venv', '_build', 'buck-out', 'build', 'dist', 'node_modules', 'venv',
34
+ ]
35
+ skip_gitignore = true
@@ -0,0 +1,2 @@
1
+ fastapi==0.109.2
2
+ pydantic==2.6