fastapi

Форк
0
/
test_schema_extra_examples.py 
966 строк · 37.7 Кб
1
from typing import Union
2

3
import pytest
4
from dirty_equals import IsDict
5
from fastapi import Body, Cookie, FastAPI, Header, Path, Query
6
from fastapi._compat import PYDANTIC_V2
7
from fastapi.testclient import TestClient
8
from pydantic import BaseModel, ConfigDict
9

10

11
def create_app():
12
    app = FastAPI()
13

14
    class Item(BaseModel):
15
        data: str
16

17
        if PYDANTIC_V2:
18
            model_config = ConfigDict(
19
                json_schema_extra={"example": {"data": "Data in schema_extra"}}
20
            )
21
        else:
22

23
            class Config:
24
                schema_extra = {"example": {"data": "Data in schema_extra"}}
25

26
    @app.post("/schema_extra/")
27
    def schema_extra(item: Item):
28
        return item
29

30
    with pytest.warns(DeprecationWarning):
31

32
        @app.post("/example/")
33
        def example(item: Item = Body(example={"data": "Data in Body example"})):
34
            return item
35

36
    @app.post("/examples/")
37
    def examples(
38
        item: Item = Body(
39
            examples=[
40
                {"data": "Data in Body examples, example1"},
41
                {"data": "Data in Body examples, example2"},
42
            ],
43
        ),
44
    ):
45
        return item
46

47
    with pytest.warns(DeprecationWarning):
48

49
        @app.post("/example_examples/")
50
        def example_examples(
51
            item: Item = Body(
52
                example={"data": "Overridden example"},
53
                examples=[
54
                    {"data": "examples example_examples 1"},
55
                    {"data": "examples example_examples 2"},
56
                ],
57
            ),
58
        ):
59
            return item
60

61
    # TODO: enable these tests once/if Form(embed=False) is supported
62
    # TODO: In that case, define if File() should support example/examples too
63
    # @app.post("/form_example")
64
    # def form_example(firstname: str = Form(example="John")):
65
    #     return firstname
66

67
    # @app.post("/form_examples")
68
    # def form_examples(
69
    #     lastname: str = Form(
70
    #         ...,
71
    #         examples={
72
    #             "example1": {"summary": "last name summary", "value": "Doe"},
73
    #             "example2": {"value": "Doesn't"},
74
    #         },
75
    #     ),
76
    # ):
77
    #     return lastname
78

79
    # @app.post("/form_example_examples")
80
    # def form_example_examples(
81
    #     lastname: str = Form(
82
    #         ...,
83
    #         example="Doe overridden",
84
    #         examples={
85
    #             "example1": {"summary": "last name summary", "value": "Doe"},
86
    #             "example2": {"value": "Doesn't"},
87
    #         },
88
    #     ),
89
    # ):
90
    #     return lastname
91

92
    with pytest.warns(DeprecationWarning):
93

94
        @app.get("/path_example/{item_id}")
95
        def path_example(
96
            item_id: str = Path(
97
                example="item_1",
98
            ),
99
        ):
100
            return item_id
101

102
    @app.get("/path_examples/{item_id}")
103
    def path_examples(
104
        item_id: str = Path(
105
            examples=["item_1", "item_2"],
106
        ),
107
    ):
108
        return item_id
109

110
    with pytest.warns(DeprecationWarning):
111

112
        @app.get("/path_example_examples/{item_id}")
113
        def path_example_examples(
114
            item_id: str = Path(
115
                example="item_overridden",
116
                examples=["item_1", "item_2"],
117
            ),
118
        ):
119
            return item_id
120

121
    with pytest.warns(DeprecationWarning):
122

123
        @app.get("/query_example/")
124
        def query_example(
125
            data: Union[str, None] = Query(
126
                default=None,
127
                example="query1",
128
            ),
129
        ):
130
            return data
131

132
    @app.get("/query_examples/")
133
    def query_examples(
134
        data: Union[str, None] = Query(
135
            default=None,
136
            examples=["query1", "query2"],
137
        ),
138
    ):
139
        return data
140

141
    with pytest.warns(DeprecationWarning):
142

143
        @app.get("/query_example_examples/")
144
        def query_example_examples(
145
            data: Union[str, None] = Query(
146
                default=None,
147
                example="query_overridden",
148
                examples=["query1", "query2"],
149
            ),
150
        ):
151
            return data
152

153
    with pytest.warns(DeprecationWarning):
154

155
        @app.get("/header_example/")
156
        def header_example(
157
            data: Union[str, None] = Header(
158
                default=None,
159
                example="header1",
160
            ),
161
        ):
162
            return data
163

164
    @app.get("/header_examples/")
165
    def header_examples(
166
        data: Union[str, None] = Header(
167
            default=None,
168
            examples=[
169
                "header1",
170
                "header2",
171
            ],
172
        ),
173
    ):
174
        return data
175

176
    with pytest.warns(DeprecationWarning):
177

178
        @app.get("/header_example_examples/")
179
        def header_example_examples(
180
            data: Union[str, None] = Header(
181
                default=None,
182
                example="header_overridden",
183
                examples=["header1", "header2"],
184
            ),
185
        ):
186
            return data
187

188
    with pytest.warns(DeprecationWarning):
189

190
        @app.get("/cookie_example/")
191
        def cookie_example(
192
            data: Union[str, None] = Cookie(
193
                default=None,
194
                example="cookie1",
195
            ),
196
        ):
197
            return data
198

199
    @app.get("/cookie_examples/")
200
    def cookie_examples(
201
        data: Union[str, None] = Cookie(
202
            default=None,
203
            examples=["cookie1", "cookie2"],
204
        ),
205
    ):
206
        return data
207

208
    with pytest.warns(DeprecationWarning):
209

210
        @app.get("/cookie_example_examples/")
211
        def cookie_example_examples(
212
            data: Union[str, None] = Cookie(
213
                default=None,
214
                example="cookie_overridden",
215
                examples=["cookie1", "cookie2"],
216
            ),
217
        ):
218
            return data
219

220
    return app
221

222

223
def test_call_api():
224
    app = create_app()
225
    client = TestClient(app)
226
    response = client.post("/schema_extra/", json={"data": "Foo"})
227
    assert response.status_code == 200, response.text
228
    response = client.post("/example/", json={"data": "Foo"})
229
    assert response.status_code == 200, response.text
230
    response = client.post("/examples/", json={"data": "Foo"})
231
    assert response.status_code == 200, response.text
232
    response = client.post("/example_examples/", json={"data": "Foo"})
233
    assert response.status_code == 200, response.text
234
    response = client.get("/path_example/foo")
235
    assert response.status_code == 200, response.text
236
    response = client.get("/path_examples/foo")
237
    assert response.status_code == 200, response.text
238
    response = client.get("/path_example_examples/foo")
239
    assert response.status_code == 200, response.text
240
    response = client.get("/query_example/")
241
    assert response.status_code == 200, response.text
242
    response = client.get("/query_examples/")
243
    assert response.status_code == 200, response.text
244
    response = client.get("/query_example_examples/")
245
    assert response.status_code == 200, response.text
246
    response = client.get("/header_example/")
247
    assert response.status_code == 200, response.text
248
    response = client.get("/header_examples/")
249
    assert response.status_code == 200, response.text
250
    response = client.get("/header_example_examples/")
251
    assert response.status_code == 200, response.text
252
    response = client.get("/cookie_example/")
253
    assert response.status_code == 200, response.text
254
    response = client.get("/cookie_examples/")
255
    assert response.status_code == 200, response.text
256
    response = client.get("/cookie_example_examples/")
257
    assert response.status_code == 200, response.text
258

259

260
def test_openapi_schema():
261
    """
262
    Test that example overrides work:
263

264
    * pydantic model schema_extra is included
265
    * Body(example={}) overrides schema_extra in pydantic model
266
    * Body(examples{}) overrides Body(example={}) and schema_extra in pydantic model
267
    """
268
    app = create_app()
269
    client = TestClient(app)
270
    response = client.get("/openapi.json")
271
    assert response.status_code == 200, response.text
272
    assert response.json() == {
273
        "openapi": "3.1.0",
274
        "info": {"title": "FastAPI", "version": "0.1.0"},
275
        "paths": {
276
            "/schema_extra/": {
277
                "post": {
278
                    "summary": "Schema Extra",
279
                    "operationId": "schema_extra_schema_extra__post",
280
                    "requestBody": {
281
                        "content": {
282
                            "application/json": {
283
                                "schema": {"$ref": "#/components/schemas/Item"}
284
                            }
285
                        },
286
                        "required": True,
287
                    },
288
                    "responses": {
289
                        "200": {
290
                            "description": "Successful Response",
291
                            "content": {"application/json": {"schema": {}}},
292
                        },
293
                        "422": {
294
                            "description": "Validation Error",
295
                            "content": {
296
                                "application/json": {
297
                                    "schema": {
298
                                        "$ref": "#/components/schemas/HTTPValidationError"
299
                                    }
300
                                }
301
                            },
302
                        },
303
                    },
304
                }
305
            },
306
            "/example/": {
307
                "post": {
308
                    "summary": "Example",
309
                    "operationId": "example_example__post",
310
                    "requestBody": {
311
                        "content": {
312
                            "application/json": {
313
                                "schema": {"$ref": "#/components/schemas/Item"},
314
                                "example": {"data": "Data in Body example"},
315
                            }
316
                        },
317
                        "required": True,
318
                    },
319
                    "responses": {
320
                        "200": {
321
                            "description": "Successful Response",
322
                            "content": {"application/json": {"schema": {}}},
323
                        },
324
                        "422": {
325
                            "description": "Validation Error",
326
                            "content": {
327
                                "application/json": {
328
                                    "schema": {
329
                                        "$ref": "#/components/schemas/HTTPValidationError"
330
                                    }
331
                                }
332
                            },
333
                        },
334
                    },
335
                }
336
            },
337
            "/examples/": {
338
                "post": {
339
                    "summary": "Examples",
340
                    "operationId": "examples_examples__post",
341
                    "requestBody": {
342
                        "content": {
343
                            "application/json": {
344
                                "schema": IsDict(
345
                                    {
346
                                        "$ref": "#/components/schemas/Item",
347
                                        "examples": [
348
                                            {"data": "Data in Body examples, example1"},
349
                                            {"data": "Data in Body examples, example2"},
350
                                        ],
351
                                    }
352
                                )
353
                                | IsDict(
354
                                    # TODO: remove this when deprecating Pydantic v1
355
                                    {
356
                                        "allOf": [
357
                                            {"$ref": "#/components/schemas/Item"}
358
                                        ],
359
                                        "title": "Item",
360
                                        "examples": [
361
                                            {"data": "Data in Body examples, example1"},
362
                                            {"data": "Data in Body examples, example2"},
363
                                        ],
364
                                    }
365
                                )
366
                            }
367
                        },
368
                        "required": True,
369
                    },
370
                    "responses": {
371
                        "200": {
372
                            "description": "Successful Response",
373
                            "content": {"application/json": {"schema": {}}},
374
                        },
375
                        "422": {
376
                            "description": "Validation Error",
377
                            "content": {
378
                                "application/json": {
379
                                    "schema": {
380
                                        "$ref": "#/components/schemas/HTTPValidationError"
381
                                    }
382
                                }
383
                            },
384
                        },
385
                    },
386
                }
387
            },
388
            "/example_examples/": {
389
                "post": {
390
                    "summary": "Example Examples",
391
                    "operationId": "example_examples_example_examples__post",
392
                    "requestBody": {
393
                        "content": {
394
                            "application/json": {
395
                                "schema": IsDict(
396
                                    {
397
                                        "$ref": "#/components/schemas/Item",
398
                                        "examples": [
399
                                            {"data": "examples example_examples 1"},
400
                                            {"data": "examples example_examples 2"},
401
                                        ],
402
                                    }
403
                                )
404
                                | IsDict(
405
                                    # TODO: remove this when deprecating Pydantic v1
406
                                    {
407
                                        "allOf": [
408
                                            {"$ref": "#/components/schemas/Item"}
409
                                        ],
410
                                        "title": "Item",
411
                                        "examples": [
412
                                            {"data": "examples example_examples 1"},
413
                                            {"data": "examples example_examples 2"},
414
                                        ],
415
                                    },
416
                                ),
417
                                "example": {"data": "Overridden example"},
418
                            }
419
                        },
420
                        "required": True,
421
                    },
422
                    "responses": {
423
                        "200": {
424
                            "description": "Successful Response",
425
                            "content": {"application/json": {"schema": {}}},
426
                        },
427
                        "422": {
428
                            "description": "Validation Error",
429
                            "content": {
430
                                "application/json": {
431
                                    "schema": {
432
                                        "$ref": "#/components/schemas/HTTPValidationError"
433
                                    }
434
                                }
435
                            },
436
                        },
437
                    },
438
                }
439
            },
440
            "/path_example/{item_id}": {
441
                "get": {
442
                    "summary": "Path Example",
443
                    "operationId": "path_example_path_example__item_id__get",
444
                    "parameters": [
445
                        {
446
                            "required": True,
447
                            "schema": {"title": "Item Id", "type": "string"},
448
                            "example": "item_1",
449
                            "name": "item_id",
450
                            "in": "path",
451
                        }
452
                    ],
453
                    "responses": {
454
                        "200": {
455
                            "description": "Successful Response",
456
                            "content": {"application/json": {"schema": {}}},
457
                        },
458
                        "422": {
459
                            "description": "Validation Error",
460
                            "content": {
461
                                "application/json": {
462
                                    "schema": {
463
                                        "$ref": "#/components/schemas/HTTPValidationError"
464
                                    }
465
                                }
466
                            },
467
                        },
468
                    },
469
                }
470
            },
471
            "/path_examples/{item_id}": {
472
                "get": {
473
                    "summary": "Path Examples",
474
                    "operationId": "path_examples_path_examples__item_id__get",
475
                    "parameters": [
476
                        {
477
                            "required": True,
478
                            "schema": {
479
                                "title": "Item Id",
480
                                "type": "string",
481
                                "examples": ["item_1", "item_2"],
482
                            },
483
                            "name": "item_id",
484
                            "in": "path",
485
                        }
486
                    ],
487
                    "responses": {
488
                        "200": {
489
                            "description": "Successful Response",
490
                            "content": {"application/json": {"schema": {}}},
491
                        },
492
                        "422": {
493
                            "description": "Validation Error",
494
                            "content": {
495
                                "application/json": {
496
                                    "schema": {
497
                                        "$ref": "#/components/schemas/HTTPValidationError"
498
                                    }
499
                                }
500
                            },
501
                        },
502
                    },
503
                }
504
            },
505
            "/path_example_examples/{item_id}": {
506
                "get": {
507
                    "summary": "Path Example Examples",
508
                    "operationId": "path_example_examples_path_example_examples__item_id__get",
509
                    "parameters": [
510
                        {
511
                            "required": True,
512
                            "schema": {
513
                                "title": "Item Id",
514
                                "type": "string",
515
                                "examples": ["item_1", "item_2"],
516
                            },
517
                            "example": "item_overridden",
518
                            "name": "item_id",
519
                            "in": "path",
520
                        }
521
                    ],
522
                    "responses": {
523
                        "200": {
524
                            "description": "Successful Response",
525
                            "content": {"application/json": {"schema": {}}},
526
                        },
527
                        "422": {
528
                            "description": "Validation Error",
529
                            "content": {
530
                                "application/json": {
531
                                    "schema": {
532
                                        "$ref": "#/components/schemas/HTTPValidationError"
533
                                    }
534
                                }
535
                            },
536
                        },
537
                    },
538
                }
539
            },
540
            "/query_example/": {
541
                "get": {
542
                    "summary": "Query Example",
543
                    "operationId": "query_example_query_example__get",
544
                    "parameters": [
545
                        {
546
                            "required": False,
547
                            "schema": IsDict(
548
                                {
549
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
550
                                    "title": "Data",
551
                                }
552
                            )
553
                            | IsDict(
554
                                # TODO: Remove this when deprecating Pydantic v1
555
                                {"title": "Data", "type": "string"}
556
                            ),
557
                            "example": "query1",
558
                            "name": "data",
559
                            "in": "query",
560
                        }
561
                    ],
562
                    "responses": {
563
                        "200": {
564
                            "description": "Successful Response",
565
                            "content": {"application/json": {"schema": {}}},
566
                        },
567
                        "422": {
568
                            "description": "Validation Error",
569
                            "content": {
570
                                "application/json": {
571
                                    "schema": {
572
                                        "$ref": "#/components/schemas/HTTPValidationError"
573
                                    }
574
                                }
575
                            },
576
                        },
577
                    },
578
                }
579
            },
580
            "/query_examples/": {
581
                "get": {
582
                    "summary": "Query Examples",
583
                    "operationId": "query_examples_query_examples__get",
584
                    "parameters": [
585
                        {
586
                            "required": False,
587
                            "schema": IsDict(
588
                                {
589
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
590
                                    "title": "Data",
591
                                    "examples": ["query1", "query2"],
592
                                }
593
                            )
594
                            | IsDict(
595
                                # TODO: Remove this when deprecating Pydantic v1
596
                                {
597
                                    "type": "string",
598
                                    "title": "Data",
599
                                    "examples": ["query1", "query2"],
600
                                }
601
                            ),
602
                            "name": "data",
603
                            "in": "query",
604
                        }
605
                    ],
606
                    "responses": {
607
                        "200": {
608
                            "description": "Successful Response",
609
                            "content": {"application/json": {"schema": {}}},
610
                        },
611
                        "422": {
612
                            "description": "Validation Error",
613
                            "content": {
614
                                "application/json": {
615
                                    "schema": {
616
                                        "$ref": "#/components/schemas/HTTPValidationError"
617
                                    }
618
                                }
619
                            },
620
                        },
621
                    },
622
                }
623
            },
624
            "/query_example_examples/": {
625
                "get": {
626
                    "summary": "Query Example Examples",
627
                    "operationId": "query_example_examples_query_example_examples__get",
628
                    "parameters": [
629
                        {
630
                            "required": False,
631
                            "schema": IsDict(
632
                                {
633
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
634
                                    "title": "Data",
635
                                    "examples": ["query1", "query2"],
636
                                }
637
                            )
638
                            | IsDict(
639
                                # TODO: Remove this when deprecating Pydantic v1
640
                                {
641
                                    "type": "string",
642
                                    "title": "Data",
643
                                    "examples": ["query1", "query2"],
644
                                }
645
                            ),
646
                            "example": "query_overridden",
647
                            "name": "data",
648
                            "in": "query",
649
                        }
650
                    ],
651
                    "responses": {
652
                        "200": {
653
                            "description": "Successful Response",
654
                            "content": {"application/json": {"schema": {}}},
655
                        },
656
                        "422": {
657
                            "description": "Validation Error",
658
                            "content": {
659
                                "application/json": {
660
                                    "schema": {
661
                                        "$ref": "#/components/schemas/HTTPValidationError"
662
                                    }
663
                                }
664
                            },
665
                        },
666
                    },
667
                }
668
            },
669
            "/header_example/": {
670
                "get": {
671
                    "summary": "Header Example",
672
                    "operationId": "header_example_header_example__get",
673
                    "parameters": [
674
                        {
675
                            "required": False,
676
                            "schema": IsDict(
677
                                {
678
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
679
                                    "title": "Data",
680
                                }
681
                            )
682
                            | IsDict(
683
                                # TODO: Remove this when deprecating Pydantic v1
684
                                {"title": "Data", "type": "string"}
685
                            ),
686
                            "example": "header1",
687
                            "name": "data",
688
                            "in": "header",
689
                        }
690
                    ],
691
                    "responses": {
692
                        "200": {
693
                            "description": "Successful Response",
694
                            "content": {"application/json": {"schema": {}}},
695
                        },
696
                        "422": {
697
                            "description": "Validation Error",
698
                            "content": {
699
                                "application/json": {
700
                                    "schema": {
701
                                        "$ref": "#/components/schemas/HTTPValidationError"
702
                                    }
703
                                }
704
                            },
705
                        },
706
                    },
707
                }
708
            },
709
            "/header_examples/": {
710
                "get": {
711
                    "summary": "Header Examples",
712
                    "operationId": "header_examples_header_examples__get",
713
                    "parameters": [
714
                        {
715
                            "required": False,
716
                            "schema": IsDict(
717
                                {
718
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
719
                                    "title": "Data",
720
                                    "examples": ["header1", "header2"],
721
                                }
722
                            )
723
                            | IsDict(
724
                                # TODO: Remove this when deprecating Pydantic v1
725
                                {
726
                                    "type": "string",
727
                                    "title": "Data",
728
                                    "examples": ["header1", "header2"],
729
                                }
730
                            ),
731
                            "name": "data",
732
                            "in": "header",
733
                        }
734
                    ],
735
                    "responses": {
736
                        "200": {
737
                            "description": "Successful Response",
738
                            "content": {"application/json": {"schema": {}}},
739
                        },
740
                        "422": {
741
                            "description": "Validation Error",
742
                            "content": {
743
                                "application/json": {
744
                                    "schema": {
745
                                        "$ref": "#/components/schemas/HTTPValidationError"
746
                                    }
747
                                }
748
                            },
749
                        },
750
                    },
751
                }
752
            },
753
            "/header_example_examples/": {
754
                "get": {
755
                    "summary": "Header Example Examples",
756
                    "operationId": "header_example_examples_header_example_examples__get",
757
                    "parameters": [
758
                        {
759
                            "required": False,
760
                            "schema": IsDict(
761
                                {
762
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
763
                                    "title": "Data",
764
                                    "examples": ["header1", "header2"],
765
                                }
766
                            )
767
                            | IsDict(
768
                                # TODO: Remove this when deprecating Pydantic v1
769
                                {
770
                                    "title": "Data",
771
                                    "type": "string",
772
                                    "examples": ["header1", "header2"],
773
                                }
774
                            ),
775
                            "example": "header_overridden",
776
                            "name": "data",
777
                            "in": "header",
778
                        }
779
                    ],
780
                    "responses": {
781
                        "200": {
782
                            "description": "Successful Response",
783
                            "content": {"application/json": {"schema": {}}},
784
                        },
785
                        "422": {
786
                            "description": "Validation Error",
787
                            "content": {
788
                                "application/json": {
789
                                    "schema": {
790
                                        "$ref": "#/components/schemas/HTTPValidationError"
791
                                    }
792
                                }
793
                            },
794
                        },
795
                    },
796
                }
797
            },
798
            "/cookie_example/": {
799
                "get": {
800
                    "summary": "Cookie Example",
801
                    "operationId": "cookie_example_cookie_example__get",
802
                    "parameters": [
803
                        {
804
                            "required": False,
805
                            "schema": IsDict(
806
                                {
807
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
808
                                    "title": "Data",
809
                                }
810
                            )
811
                            | IsDict(
812
                                # TODO: Remove this when deprecating Pydantic v1
813
                                {"title": "Data", "type": "string"}
814
                            ),
815
                            "example": "cookie1",
816
                            "name": "data",
817
                            "in": "cookie",
818
                        }
819
                    ],
820
                    "responses": {
821
                        "200": {
822
                            "description": "Successful Response",
823
                            "content": {"application/json": {"schema": {}}},
824
                        },
825
                        "422": {
826
                            "description": "Validation Error",
827
                            "content": {
828
                                "application/json": {
829
                                    "schema": {
830
                                        "$ref": "#/components/schemas/HTTPValidationError"
831
                                    }
832
                                }
833
                            },
834
                        },
835
                    },
836
                }
837
            },
838
            "/cookie_examples/": {
839
                "get": {
840
                    "summary": "Cookie Examples",
841
                    "operationId": "cookie_examples_cookie_examples__get",
842
                    "parameters": [
843
                        {
844
                            "required": False,
845
                            "schema": IsDict(
846
                                {
847
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
848
                                    "title": "Data",
849
                                    "examples": ["cookie1", "cookie2"],
850
                                }
851
                            )
852
                            | IsDict(
853
                                # TODO: Remove this when deprecating Pydantic v1
854
                                {
855
                                    "title": "Data",
856
                                    "type": "string",
857
                                    "examples": ["cookie1", "cookie2"],
858
                                }
859
                            ),
860
                            "name": "data",
861
                            "in": "cookie",
862
                        }
863
                    ],
864
                    "responses": {
865
                        "200": {
866
                            "description": "Successful Response",
867
                            "content": {"application/json": {"schema": {}}},
868
                        },
869
                        "422": {
870
                            "description": "Validation Error",
871
                            "content": {
872
                                "application/json": {
873
                                    "schema": {
874
                                        "$ref": "#/components/schemas/HTTPValidationError"
875
                                    }
876
                                }
877
                            },
878
                        },
879
                    },
880
                }
881
            },
882
            "/cookie_example_examples/": {
883
                "get": {
884
                    "summary": "Cookie Example Examples",
885
                    "operationId": "cookie_example_examples_cookie_example_examples__get",
886
                    "parameters": [
887
                        {
888
                            "required": False,
889
                            "schema": IsDict(
890
                                {
891
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
892
                                    "title": "Data",
893
                                    "examples": ["cookie1", "cookie2"],
894
                                }
895
                            )
896
                            | IsDict(
897
                                # TODO: Remove this when deprecating Pydantic v1
898
                                {
899
                                    "title": "Data",
900
                                    "type": "string",
901
                                    "examples": ["cookie1", "cookie2"],
902
                                }
903
                            ),
904
                            "example": "cookie_overridden",
905
                            "name": "data",
906
                            "in": "cookie",
907
                        }
908
                    ],
909
                    "responses": {
910
                        "200": {
911
                            "description": "Successful Response",
912
                            "content": {"application/json": {"schema": {}}},
913
                        },
914
                        "422": {
915
                            "description": "Validation Error",
916
                            "content": {
917
                                "application/json": {
918
                                    "schema": {
919
                                        "$ref": "#/components/schemas/HTTPValidationError"
920
                                    }
921
                                }
922
                            },
923
                        },
924
                    },
925
                }
926
            },
927
        },
928
        "components": {
929
            "schemas": {
930
                "HTTPValidationError": {
931
                    "title": "HTTPValidationError",
932
                    "type": "object",
933
                    "properties": {
934
                        "detail": {
935
                            "title": "Detail",
936
                            "type": "array",
937
                            "items": {"$ref": "#/components/schemas/ValidationError"},
938
                        }
939
                    },
940
                },
941
                "Item": {
942
                    "title": "Item",
943
                    "required": ["data"],
944
                    "type": "object",
945
                    "properties": {"data": {"title": "Data", "type": "string"}},
946
                    "example": {"data": "Data in schema_extra"},
947
                },
948
                "ValidationError": {
949
                    "title": "ValidationError",
950
                    "required": ["loc", "msg", "type"],
951
                    "type": "object",
952
                    "properties": {
953
                        "loc": {
954
                            "title": "Location",
955
                            "type": "array",
956
                            "items": {
957
                                "anyOf": [{"type": "string"}, {"type": "integer"}]
958
                            },
959
                        },
960
                        "msg": {"title": "Message", "type": "string"},
961
                        "type": {"title": "Error Type", "type": "string"},
962
                    },
963
                },
964
            }
965
        },
966
    }
967

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.