@@ -129,7 +129,7 @@ security = [{"jwt": []}]
129
129
app = OpenAPI(__name__ , info = info, security_schemes = security_schemes)
130
130
```
131
131
132
- Second, add pass the ** security** to your api, like this:
132
+ Second, add pass the [ ** security** ] ( ./Route_Operation.md#security ) to your api, like this:
133
133
134
134
``` python hl_lines="1"
135
135
@app.get (' /book/<int:bid>' , tags = [book_tag], security = security)
@@ -141,22 +141,6 @@ result:
141
141
142
142
![ image-20210525165350520] ( ../assets/image-20210525165350520.png )
143
143
144
- ### abp_security
145
-
146
- * New in v0.9.3*
147
-
148
- You don't need to specify ** security** for every api.
149
-
150
- ``` python hl_lines="3"
151
- tag = Tag(name = ' book' , description = " Some Book" )
152
- security = [{" jwt" : []}]
153
- api = APIBlueprint(' /book' , __name__ , abp_tags = [tag], abp_security = security)
154
-
155
-
156
- @api.post (' /book' )
157
- def create_book (body : BookBody):
158
- ...
159
- ```
160
144
161
145
## oauth_config
162
146
@@ -226,11 +210,11 @@ def endpoint():
226
210
...
227
211
```
228
212
229
- ### abp_responses
213
+ ## abp_responses & view_responses
230
214
231
215
* New in v0.9.4*
232
216
233
- You can add ` responses ` for each API under the ` api ` wrapper.
217
+ You can add ` responses ` for each API under the ` api ` or ` api_view ` wrapper.
234
218
235
219
``` python hl_lines="10"
236
220
class Unauthorized (BaseModel ):
@@ -239,10 +223,15 @@ class Unauthorized(BaseModel):
239
223
240
224
241
225
api = APIBlueprint(
242
- ' /book' ,
226
+ " /book" ,
243
227
__name__ ,
244
- url_prefix = ' /api' ,
245
- abp_responses = {" 401" : Unauthorized}
228
+ url_prefix = " /api" ,
229
+ abp_responses = {401 : Unauthorized}
230
+ )
231
+
232
+ api_view = APIView(
233
+ " /book" ,
234
+ view_responses = {401 : Unauthorized}
246
235
)
247
236
248
237
@api.get (... )
@@ -262,15 +251,15 @@ You can also use [responses ](./Response.md#responses) and [extra_responses](./R
262
251
263
252
## doc_ui
264
253
265
- You can pass ` doc_ui=False ` to disable the ` OpenAPI spec ` when init ` OpenAPI ` .
254
+ You can pass ` doc_ui=False ` to disable the ` OpenAPI spec ` when init [ ` OpenAPI ` ] ( ../Reference/OpenAPI.md ) .
266
255
267
256
``` python
268
257
app = OpenAPI(__name__ , info = info, doc_ui = False )
269
258
```
270
259
271
260
* New in v0.9.4*
272
261
273
- You can also use ` doc_ui ` in endpoint or when initializing ` APIBlueprint ` .
262
+ You can also use ` doc_ui ` in endpoint or when initializing [ ` APIBlueprint ` ] ( ../Reference/APIBlueprint.md ) or [ ` APIView ` ] ( ../Reference/APIView.md ) .
274
263
275
264
``` python hl_lines="4 9"
276
265
api = APIBlueprint(
0 commit comments