FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-schema-validator/benchmarks/cases.py at master · python-openapi/openapi-schema-validator · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python-openapi
/
openapi-schema-validator
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
37
Star
126
Code
Issues
1
Pull requests
14
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-schema-validator
/
benchmarks
/
cases.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
171 lines (164 loc) · 6.12 KB
Breadcrumbs
openapi-schema-validator
/
benchmarks
/
cases.py
Copy path
File metadata and controls
171 lines (164 loc) · 6.12 KB
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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from
dataclasses
import
dataclass
from
typing
import
Any
from
referencing
import
Registry
from
referencing
import
Resource
from
referencing
.
jsonschema
import
DRAFT202012
from
openapi_schema_validator
import
OAS30Validator
from
openapi_schema_validator
import
OAS31Validator
from
openapi_schema_validator
import
OAS32Validator
from
openapi_schema_validator
import
oas30_format_checker
from
openapi_schema_validator
import
oas31_format_checker
from
openapi_schema_validator
import
oas32_format_checker
@
dataclass
(
frozen
=
True
)
class
BenchmarkCase
:
name
:
str
validator_class
:
Any
schema
:
dict
[
str
,
Any
]
instance
:
Any
validator_kwargs
:
dict
[
str
,
Any
]
def
build_cases
()
->
list
[
BenchmarkCase
]:
name_schema
=
Resource
.
from_contents
(
{
"$schema"
:
"https://json-schema.org/draft/2020-12/schema"
,
"type"
:
"string"
,
}
)
age_schema
=
DRAFT202012
.
create_resource
(
{
"type"
:
"integer"
,
"format"
:
"int32"
,
"minimum"
:
0
,
"maximum"
:
120
,
}
)
registry
=
Registry
().
with_resources
(
[
(
"urn:name-schema"
,
name_schema
),
(
"urn:age-schema"
,
age_schema
),
]
)
return
[
BenchmarkCase
(
name
=
"oas32_simple_object"
,
validator_class
=
OAS32Validator
,
schema
=
{
"type"
:
"object"
,
"required"
: [
"name"
],
"properties"
: {
"name"
: {
"type"
:
"string"
},
"enabled"
: {
"type"
:
"boolean"
},
},
"additionalProperties"
:
False
,
},
instance
=
{
"name"
:
"svc"
,
"enabled"
:
True
},
validator_kwargs
=
{
"format_checker"
:
oas32_format_checker
},
),
BenchmarkCase
(
name
=
"oas31_prefix_items"
,
validator_class
=
OAS31Validator
,
schema
=
{
"type"
:
"array"
,
"prefixItems"
: [
{
"type"
:
"number"
},
{
"type"
:
"string"
},
{
"enum"
: [
"Street"
,
"Avenue"
,
"Boulevard"
]},
{
"enum"
: [
"NW"
,
"NE"
,
"SW"
,
"SE"
]},
],
"items"
:
False
,
},
instance
=
[
1600
,
"Pennsylvania"
,
"Avenue"
,
"NW"
],
validator_kwargs
=
{
"format_checker"
:
oas31_format_checker
},
),
BenchmarkCase
(
name
=
"oas30_nullable"
,
validator_class
=
OAS30Validator
,
schema
=
{
"type"
:
"string"
,
"nullable"
:
True
},
instance
=
None
,
validator_kwargs
=
{
"format_checker"
:
oas30_format_checker
},
),
BenchmarkCase
(
name
=
"oas30_discriminator"
,
validator_class
=
OAS30Validator
,
schema
=
{
"$ref"
:
"#/components/schemas/Route"
,
"components"
: {
"schemas"
: {
"MountainHiking"
: {
"type"
:
"object"
,
"properties"
: {
"discipline"
: {
"type"
:
"string"
,
"enum"
: [
"mountain_hiking"
,
"MountainHiking"
,
],
},
"length"
: {
"type"
:
"integer"
},
},
"required"
: [
"discipline"
,
"length"
],
},
"AlpineClimbing"
: {
"type"
:
"object"
,
"properties"
: {
"discipline"
: {
"type"
:
"string"
,
"enum"
: [
"alpine_climbing"
],
},
"height"
: {
"type"
:
"integer"
},
},
"required"
: [
"discipline"
,
"height"
],
},
"Route"
: {
"oneOf"
: [
{
"$ref"
: (
"#/components/schemas/"
"MountainHiking"
)
},
{
"$ref"
: (
"#/components/schemas/"
"AlpineClimbing"
)
},
],
"discriminator"
: {
"propertyName"
:
"discipline"
,
"mapping"
: {
"mountain_hiking"
: (
"#/components/schemas/"
"MountainHiking"
),
"alpine_climbing"
: (
"#/components/schemas/"
"AlpineClimbing"
),
},
},
},
}
},
},
instance
=
{
"discipline"
:
"mountain_hiking"
,
"length"
:
10
},
validator_kwargs
=
{
"format_checker"
:
oas30_format_checker
},
),
BenchmarkCase
(
name
=
"oas32_registry_refs"
,
validator_class
=
OAS32Validator
,
schema
=
{
"type"
:
"object"
,
"required"
: [
"name"
],
"properties"
: {
"name"
: {
"$ref"
:
"urn:name-schema"
},
"age"
: {
"$ref"
:
"urn:age-schema"
},
},
"additionalProperties"
:
False
,
},
instance
=
{
"name"
:
"John"
,
"age"
:
23
},
validator_kwargs
=
{
"format_checker"
:
oas32_format_checker
,
"registry"
:
registry
,
},
),
]
Back
|
FazBrowse Home
|
New Git URL