Skip to content

Commit 68fb5a9

Browse files
authored
[python-experimental] consolidates endpoints into paths module (#13007)
* Adds endpoint creation in path modules * REgens samples * Adds BaseApi so there can be 2 class interfaces for http method and operationid * Adds paths init * Adds enum containing paths * Uses path enum for endpoint paths * Adds camel case to undersce converstion in to ineum var name * Fixes path enum generation * Moves path api combination module into apis * Moves tag apis into a tags module * Adds path_to_api * Changes module path to paths * Fixes tag api imports * Fixes self type in endpoint methods * Adds test changes * Adds tag enum * Adds tag_to_api * Adds missing tag * Fixes self types in endpoint methods * Refactors java endpoint generation to be simpler * Further refactors generateEndpoints * Generates one test file per endpoint * Updates v3 samples * Fixes endpoint tests, all tests passing now * Samples regenerated * Fixes petstore tests * Generates separate endpoint test methods on each endpoint * Fixes api docs and enum string values in those docs * Regenerates samples * Removes pass to fix tests
1 parent 4635dda commit 68fb5a9

File tree

1,784 files changed

+84281
-155078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,784 files changed

+84281
-155078
lines changed

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

Lines changed: 263 additions & 73 deletions
Large diffs are not rendered by default.

modules/openapi-generator/src/main/resources/python-experimental/__init__api.handlebars

Lines changed: 0 additions & 9 deletions
This file was deleted.

modules/openapi-generator/src/main/resources/python-experimental/__init__api_endpoints.handlebars

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
{{#with apiInfo}}
2-
{{#each apis}}
3-
{{#if @first}}
4-
# coding: utf-8
5-
6-
# flake8: noqa
7-
8-
# Import all APIs into this package.
9-
# If you have many APIs here with many many models used in each API this may
10-
# raise a `RecursionError`.
11-
# In order to avoid this, import only the API that you directly need like:
12-
#
13-
# from {{packageName}}.{{apiPackage}}.{{classFilename}} import {{classname}}
14-
#
15-
# or import this package, but before doing it, use:
16-
#
17-
# import sys
18-
# sys.setrecursionlimit(n)
19-
20-
# Import APIs into API package:
21-
{{/if}}
22-
from {{packageName}}.{{apiPackage}}.{{classFilename}} import {{classname}}
23-
{{/each}}
24-
{{/with}}
1+
# do not import all endpoints into this module because that uses a lot of memory and stack frames
2+
# if you need the ability to import all endpoints then import them from
3+
# tags, paths, or path_to_api, or tag_to_api
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# do not import all endpoints into this module because that uses a lot of memory and stack frames
2+
# if you need the ability to import all endpoints from this module, import them with
3+
# from {{packageName}}.apis.tag_to_api import tag_to_api
4+
5+
import enum
6+
7+
8+
class TagValues(str, enum.Enum):
9+
{{#each enumToTag}}
10+
{{@key}} = "{{this}}"
11+
{{/each}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# do not import all endpoints into this module because that uses a lot of memory and stack frames
2+
# if you need the ability to import all endpoints from this module, import them with
3+
# from {{packageName}}.apis.path_to_api import path_to_api
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# do not import all endpoints into this module because that uses a lot of memory and stack frames
2+
# if you need the ability to import all endpoints from this module, import them with
3+
# from {{packageName}}.apis.path_to_api import path_to_api
4+
5+
import enum
6+
7+
8+
class PathValues(str, enum.Enum):
9+
{{#each pathValToVar}}
10+
{{this}} = "{{@key}}"
11+
{{/each}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# do not import all endpoints into this module because that uses a lot of memory and stack frames
2+
# if you need the ability to import all endpoints from this module, import them with
3+
# from {{packageName}}.paths.{{pathModule}} import {{apiClassName}}
4+
5+
from {{packageName}}.paths import PathValues
6+
7+
path = PathValues.{{{pathVar}}}

modules/openapi-generator/src/main/resources/python-experimental/api.handlebars

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
{{>partial_header}}
44

5-
from {{packageName}}.api_client import ApiClient
65
{{#with operations}}
76
{{#each operation}}
8-
from {{packageName}}.api.{{classFilename}}_endpoints.{{operationId}} import {{operationIdCamelCase}}
7+
from {{packageName}}.paths.{{nickname}}.{{httpMethod}} import {{operationIdCamelCase}}
98
{{/each}}
109
{{/with}}
1110

@@ -15,7 +14,6 @@ class {{classname}}(
1514
{{#each operation}}
1615
{{operationIdCamelCase}},
1716
{{/each}}
18-
ApiClient,
1917
):
2018
"""NOTE: This class is auto generated by OpenAPI Generator
2119
Ref: https://openapi-generator.tech

0 commit comments

Comments
 (0)