Hi again @KarimJedda ,
I am just testing your stuff, and try to see some variations on your code.
I put parameters in yaml and in the zblaaaa.get_secret function
paths:
'/stuff':
get:
tags: [stuff]
operationId: zblaaaa.get_secret
summary: Give me sugar sugar
parameters:
- name: animal_type
in: query
type: string
pattern: "^[a-zA-Z0-9]*$"
- name: limit
in: query
type: integer
minimum: 0
default: 100
responses:
200:
description: Something secret
And here zblaaaa.get_secret, just remove your link to the video (sorry!) and added pets, of course! to test the parameters
from run import jwt_required, current_identity
pets = {
"01": {
"tags": ["dino","mamal"],
"animal_type": "dino",
"id": "01",
"name": "Susie Saurio",
"created": "2016-07-07T15:49:51.230+02:00"
},
"02": {
"tags": ["dino","bird"],
"animal_type": "dino",
"id": "02",
"name": "Fly Saurio",
"created": "2015-08-07T15:44:51.230+01:00"
},
"03": {
"tags": [],
"animal_type": "bird",
"id": "03",
"name": "Piolin",
"created": "2025-08-07T15:44:51.230+01:00"
}
}
@jwt_required()
def get_secret(limit, animal_type=None):
return [pet for pet in pets.values() if not animal_type or pet['animal_type'] == animal_type][:limit]
But after requiring the access_token, write back in header i retrieve the next error pointing to
*flask_jwt/init.py", line 177 in decorator
return fn(_args, _kwargs)
TypeError: get_secret() takes at least 1 argument (0 given)
ERROR:run:Exception on /api/stuff [GET]
Traceback (most recent call last):
File "~/.pyenv/versions/miserver/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
....
File "~/.pyenv/versions/miserver/lib/python2.7/site-packages/connexion/decorators/validation.py", line 192, in wrapper
response = function(*args, **kwargs)
File "~/.pyenv/versions/miserver/lib/python2.7/site-packages/connexion/decorators/produces.py", line 117, in wrapper
data, status_code, headers = self.get_full_response(function(*args, **kwargs))
File "~/.pyenv/versions/miserver/lib/python2.7/site-packages/connexion/decorators/parameter.py", line 133, in wrapper
return function(*args, **kwargs)
File "~/.pyenv/versions/miserver/lib/python2.7/site-packages/flask_jwt/__init__.py", line 177, in decorator
return fn(*args, **kwargs)
TypeError: get_secret() takes at least 1 argument (0 given)
127.0.0.1 - - [2016-03-21 20:20:26] "GET /api/stuff?animal_type=dino&limit=100 HTTP/1.1" 500 377 0.003594
But i i remove the @jwt_required()
from get_secret
the response is 200.(OK)
So parameter definition is ok in yaml file.
Then, there is a problem in the @jwt_required() decorator. Isn't it?
Or Is in my test of this demo?
Thanks in advance