-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi3-parser-llms-full.txt
More file actions
89 lines (61 loc) · 2.05 KB
/
openapi3-parser-llms-full.txt
File metadata and controls
89 lines (61 loc) · 2.05 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# OpenAPI Parser
[](https://pypi.org/project/openapi3-parser/)
[](https://clickpy.clickhouse.com/dashboard/openapi3-parser)
[](https://pypi.org/project/openapi3-parser/)
[](https://pypi.org/project/openapi3-parser/)
[](license.txt)
A simple package to parse your OpenAPI 3 documents into Python object to work with.
Supported versions:
| Version | Status |
| ------- | -------------- |
| 2.0 | Deprecated |
| 3.0 | **Supported** |
| 3.1 | In development |
## How to install
To install package run the following command
```
pip install openapi3-parser
```
## How to use
Example of parser usage
```
>>> from openapi_parser import parse
>>> content = parse('swagger.yml')
>>> print(content)
```
Get application servers
```python
from openapi_parser import parse
specification = parse('data/swagger.yml')
print("Application servers")
for server in specification.servers:
print(f"{server.description} - {server.url}")
# Output
#
# >> Application servers
# >> production - https://users.app
# >> staging - http://stage.users.app
# >> development - http://users.local
```
Get list of application URLs
```python
from openapi_parser import parse
specification = parse('tests/data/swagger.yml')
urls = [x.url for x in specification.paths]
print(urls)
# Output
#
# >> ['/users', '/users/{uuid}']
```
Get operation with supported HTTP methods
```python
from openapi_parser import parse
specification = parse('tests/data/swagger.yml')
for path in specification.paths:
supported_methods = ','.join([x.method.value for x in path.operations])
print(f"Operation: {path.url}, methods: {supported_methods}")
# Output
#
# >> Operation: /users, methods: get,post
# >> Operation: /users/{uuid}, methods: get,put
```