@team-supercharge/oasg 13.2.0-feature-python-fastapi-064d0bcc.0 → 13.2.0-feature-csharp-functions-00ba5a99.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
@@ -656,27 +656,6 @@ TBD
656
656
 
657
657
  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.
658
658
 
659
-
660
- #### `python-fastapi`
661
-
662
- ```json
663
- {
664
- "id": "server-python",
665
- "type": "python-fastapi",
666
- "source": "source-merged",
667
- "packageName": "oasg_example",
668
- "repositoryUrl": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/pypi"
669
- }
670
- ```
671
-
672
- |Parameter| Description| Required | Default |
673
- |-|-|-|-|
674
- | packageName | Package nem for the project (convention: snake_case) | Y | - |
675
- | repositoryUrl | URL of the PyPI repository | Y | - |
676
-
677
- Building the distribution package requires Flit.
678
- 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.
679
-
680
659
  #### `contract-testing`
681
660
 
682
661
  ```json
@@ -792,6 +771,23 @@ describe('Auth', function () {
792
771
  |-|-|-|-|
793
772
  | fileName | Name of the generated file | N | `openapi.yaml` |
794
773
 
774
+ #### `csharp-functions`
775
+
776
+ ```json
777
+ {
778
+ "id": "csharp-functions",
779
+ "type": "csharp-functions",
780
+ "source": "source-merged",
781
+ "packageName": "Oasg.Example",
782
+ "generatorCustomArgs": "--additional-properties=packageName=$packageName"
783
+ }
784
+ ```
785
+
786
+ |Parameter| Description| Required | Default |
787
+ |-|-|-|-|
788
+ | packageName | C# package name (convention: Title.Case). | Y | - |
789
+ | generatorCustomArgs | Custom arguments of the generator | N | - |
790
+
795
791
  ---
796
792
 
797
793
  # Migration Guide
package/bin/oasg CHANGED
@@ -45,7 +45,7 @@ const DEFAULT_GENERATOR_MAPPING = {
45
45
  "nestjs": { version: '7.0.1', generator: 'typescript-angular' },
46
46
  "spring": { version: '7.0.1', generator: 'spring' },
47
47
  "spring-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
48
- "python-fastapi": { version: '7.0.1', generator: 'python-fastapi' },
48
+ "csharp-functions": { version: '7.0.1', generator: 'csharp-functions' },
49
49
  // misc targets
50
50
  "contract-testing": { version: '4.3.1', generator: 'typescript-node' },
51
51
  "openapi": { version: undefined, generator: undefined },
package/config.schema.yml CHANGED
@@ -20,11 +20,11 @@ properties:
20
20
  - $ref: '#/targets/Android'
21
21
  - $ref: '#/targets/ios'
22
22
  - $ref: '#/targets/Python'
23
- - $ref: '#/targets/PythonFastApi'
24
23
  - $ref: '#/targets/ContractTesting'
25
24
  - $ref: '#/targets/NestJS'
26
25
  - $ref: '#/targets/OpenAPI'
27
26
  - $ref: '#/targets/Flutter'
27
+ - $ref: '#/targets/CsharpFunctions'
28
28
  required:
29
29
  - targets
30
30
  additionalProperties: false
@@ -296,20 +296,6 @@ targets:
296
296
  - packageName
297
297
  - repositoryUrl
298
298
 
299
- PythonFastApi:
300
- allOf:
301
- - $ref: '#/targets/Base'
302
- - properties:
303
- type:
304
- pattern: "^python-fastapi$"
305
- packageName:
306
- type: string
307
- repositoryUrl:
308
- type: string
309
- required:
310
- - packageName
311
- - repositoryUrl
312
-
313
299
  ContractTesting:
314
300
  allOf:
315
301
  - $ref: '#/targets/Base'
@@ -361,6 +347,17 @@ targets:
361
347
  - packageName
362
348
  - repository
363
349
 
350
+ CsharpFunctions:
351
+ allOf:
352
+ - $ref: '#/targets/Base'
353
+ - properties:
354
+ type:
355
+ pattern: '^csharp-functions$'
356
+ packageName:
357
+ type: string
358
+ required:
359
+ - packageName
360
+
364
361
  definitions:
365
362
  # default
366
363
  SourceOverrides:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "13.2.0-feature-python-fastapi-064d0bcc.0",
3
+ "version": "13.2.0-feature-csharp-functions-00ba5a99.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
@@ -1,4 +1,5 @@
1
1
  {
2
+ "global-property": "models",
2
3
  "inlineSchemaOptions": {
3
4
  "ARRAY_ITEM_SUFFIX": "",
4
5
  "MAP_ITEM_SUFFIX": "",
@@ -0,0 +1,12 @@
1
+ #/bin/bash
2
+
3
+ # source $(dirname "$0")/../common.sh
4
+
5
+ # TODO install dotnet, nuget
6
+
7
+ # cd out/$targetId
8
+ # dotnet pack
9
+ # nuget push YourPackage.nupkg -Source https://api.nuget.org/v3/index.json
10
+ # cd ../..
11
+
12
+ echo "Publish .NET"
@@ -77,7 +77,7 @@ export class OptionalParseBoolPipe implements PipeTransform<string | boolean> {
77
77
  }
78
78
  }
79
79
 
80
- export class OptionalParseEnumPipe<T = any> implements PipeTransform<T> {
80
+ export class OptionalParseEnumPipe<T extends { [key: string]: any } = any> implements PipeTransform<T> {
81
81
  constructor(private readonly enumType: T) {
82
82
  if (!enumType) {
83
83
  throw new Error(
@@ -1,29 +0,0 @@
1
- #/bin/bash
2
-
3
- source $(dirname "$0")/../common.sh
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}"
8
-
9
- rm -rf out/$targetId
10
- mkdir -p out/$targetId
11
-
12
- java -jar $binary generate \
13
- -g $generatorId \
14
- -i $openApiFile \
15
- -t $templateDir \
16
- -o out/$targetId \
17
- -c $(dirname "$0")/generator-config.json \
18
- -p "packageVersion=$version,packageName=$packageName" $generatorCustomArgs
19
-
20
- cd out/$targetId
21
-
22
- touch "src/$packageName/__init__.py"
23
- python3 -m venv venv
24
- source venv/bin/activate
25
- pip install --upgrade pip
26
- pip install flit==3.9.0
27
- flit build --no-use-vcs
28
-
29
- cd ../../
@@ -1,9 +0,0 @@
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 ../..
@@ -1,43 +0,0 @@
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
- ```
@@ -1,62 +0,0 @@
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){{/notes}}{{^notes}}...{{/notes}}
57
- {{^-last}}
58
-
59
-
60
- {{/-last}}
61
- {{/operation}}
62
- {{/operations}}
@@ -1,29 +0,0 @@
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
- ) -> Response: # -> {{returnType}}{{^returnType}}None{{/returnType}}
23
- {{#notes}}"""{{.}}"""
24
- ...{{/notes}}{{^notes}}...{{/notes}}
25
- {{^-last}}
26
-
27
- {{/-last}}
28
- {{/operation}}
29
- {{/operations}}
@@ -1 +0,0 @@
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}})
@@ -1,35 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- fastapi==0.109.2
2
- pydantic==2.6