FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-python-client/openapi_python_client/parser/reference.py at main · ramnes/openapi-python-client · GitHub
ramnes
openapi-python-client
Repository navigation
Code
Pull requests
10
(10)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-python-client
/
openapi_python_client
/
parser
/
reference.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (18 loc) · 779 Bytes
Breadcrumbs
openapi-python-client
/
openapi_python_client
/
parser
/
reference.py
Copy path
File metadata and controls
27 lines (18 loc) · 779 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
""" A Reference is ultimately a Class which will be in models, usually defined in a body input or return type """
from
dataclasses
import
dataclass
from
typing
import
Dict
from
..
import
utils
class_overrides
:
Dict
[
str
,
"Reference"
]
=
{}
@
dataclass
class
Reference
:
""" A reference to a class which will be in models """
class_name
:
str
module_name
:
str
@
staticmethod
def
from_ref
(
ref
:
str
)
->
"Reference"
:
""" Get a Reference from the openapi #/schemas/blahblah string """
ref_value
=
ref
.
split
(
"/"
)[
-
1
]
class_name
=
utils
.
pascal_case
(
ref_value
)
if
class_name
in
class_overrides
:
return
class_overrides
[
class_name
]
return
Reference
(
class_name
=
class_name
,
module_name
=
utils
.
snake_case
(
class_name
))
Back
|
FazBrowse Home
|
New Git URL