Skip to content

Commit 29efba5

Browse files
committed
README updated
1 parent 16df885 commit 29efba5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Diff for: README.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Swagger(app)
4646
@app.route('/colors/<palette>/')
4747
def colors(palette):
4848
"""Example endpoint returning a list of colors by palette
49+
This is using docstrings for specifications.
4950
---
5051
parameters:
5152
- name: palette
@@ -144,11 +145,9 @@ def colors(palette):
144145
...
145146
```
146147
147-
If you do not want to use the decorator you can use the docsting shortcut.
148+
If you do not want to use the decorator you can use the docsting `file:` shortcut.
148149

149150
```python
150-
from flasgger import swag_from
151-
152151
@app.route('/colors/<palette>/')
153152
def colors(palette):
154153
"""
@@ -160,7 +159,7 @@ def colors(palette):
160159

161160
## Using dictionaries as raw specs
162161

163-
Create a Python dictionary with as:
162+
Create a Python dictionary as:
164163

165164
```python
166165
specs_dict = {
@@ -219,7 +218,7 @@ Now take the same function and use the dict in the place of YAML file.
219218
@swag_from(specs_dict)
220219
def colors(palette):
221220
"""Example endpoint returning a list of colors by palette
222-
In this example the specification is taken from external YAML file
221+
In this example the specification is taken from specs_dict
223222
"""
224223
...
225224
```
@@ -236,12 +235,10 @@ from flasgger import Swagger, SwaggerView, Schema, fields
236235
class Color(Schema):
237236
name = fields.Str()
238237
239-
240238
class Palette(Schema):
241239
pallete_name = fields.Str()
242240
colors = fields.Nested(Color, many=True)
243241
244-
245242
class PaletteView(SwaggerView):
246243
parameters = [
247244
{
@@ -275,7 +272,6 @@ class PaletteView(SwaggerView):
275272
result = {palette: all_colors.get(palette)}
276273
return jsonify(result)
277274
278-
279275
app = Flask(__name__)
280276
Swagger(app)
281277
@@ -313,7 +309,11 @@ def fromfile_decorated(username=None):
313309
return jsonify({'username': username})
314310
```
315311

316-
# Use the same yaml file to validate your API data
312+
And the same can be achieved with multiple methods in a `MethodView` or `SwaggerView` by
313+
registering the `url_rule` many times. Take a look at `examples/example_app`
314+
315+
316+
# Use the same data to validate your API POST body.
317317

318318
```python
319319
from flasgger import swag_from, validate
@@ -336,6 +336,9 @@ def post():
336336
# also returns the validation message.
337337
```
338338

339+
It is also possible to define `validation=True` in `SwaggerView` and also use
340+
`specs_dict` for validation.
341+
339342
Take a look at `examples/validation.py` for more information.
340343

341344
All validation options can be found at http://json-schema.org/latest/json-schema-validation.html
@@ -382,7 +385,7 @@ Swagger(app)
382385
383386
```
384387

385-
# Starting with defauts.
388+
# Initializing Flasgger with default data.
386389

387390
You can start your Swagger spec with any default data providing a template:
388391

0 commit comments

Comments
 (0)