Skip to content

Commit ceca9ff

Browse files
wing328Goopher Maijenburg
andauthored
Add package version option for python fastapi generator (OpenAPITools#23766)
* Add package version for python fastapi to be inline with openapi generator docs * update urllib3, add default --------- Co-authored-by: Goopher Maijenburg <goopher.maijenburg@twict.nl>
1 parent 0063916 commit ceca9ff

6 files changed

Lines changed: 13 additions & 4 deletions

File tree

bin/configs/python-fastapi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ templateDir: modules/openapi-generator/src/main/resources/python-fastapi
55
sourceFolder: "src"
66
additionalProperties:
77
hideGenerationTimestamp: "true"
8+
packageVersion: "3.4.5"

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public PythonFastAPIServerCodegen() {
9393
additionalProperties.put("baseSuffix", BASE_CLASS_SUFFIX);
9494
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, DEFAULT_SOURCE_FOLDER);
9595
additionalProperties.put(CodegenConstants.PACKAGE_NAME, DEFAULT_PACKAGE_NAME);
96+
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, DEFAULT_PACKAGE_VERSION);
9697
additionalProperties.put(CodegenConstants.FASTAPI_IMPLEMENTATION_PACKAGE, DEFAULT_IMPL_FOLDER);
9798

9899
languageSpecificPrimitives.add("List");
@@ -152,6 +153,13 @@ public void processOpts() {
152153

153154
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
154155
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
156+
} else {
157+
// default to appVersion in the spec
158+
setPackageName((String) additionalProperties.get("appVersion"));
159+
}
160+
161+
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
162+
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
155163
}
156164

157165
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {

modules/openapi-generator/src/main/resources/python-fastapi/requirements.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Rx==1.6.1
2929
starlette==0.49.1
3030
typing-extensions==4.13.2
3131
ujson==4.0.2
32-
urllib3==2.6.3
32+
urllib3==2.7.0
3333
uvicorn==0.13.4
3434
uvloop==0.21.0
3535
watchgod==0.7

modules/openapi-generator/src/main/resources/python-fastapi/setup_cfg.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = {{packageName}}
3-
version = {{appVersion}}
3+
version = {{packageVersion}}
44
description = {{appDescription}}
55
long_description = file: README.md
66
keywords = OpenAPI {{appName}}

samples/server/petstore/python-fastapi/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Rx==1.6.1
2929
starlette==0.49.1
3030
typing-extensions==4.13.2
3131
ujson==4.0.2
32-
urllib3==2.6.3
32+
urllib3==2.7.0
3333
uvicorn==0.13.4
3434
uvloop==0.21.0
3535
watchgod==0.7

samples/server/petstore/python-fastapi/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = openapi_server
3-
version = 1.0.0
3+
version = 3.4.5
44
description = This is a sample server Petstore server. For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.
55
long_description = file: README.md
66
keywords = OpenAPI OpenAPI Petstore

0 commit comments

Comments
 (0)