mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 20:37:46 +00:00
449 path format (#450)
* added test for path formatted parameters * re-added removed test, as it would generate valid flask route
This commit is contained in:
committed by
Henning Jacobs
parent
c30ba1f571
commit
1f34e3565b
@@ -18,6 +18,12 @@ def test_app(simple_app):
|
||||
swagger_icon = app_client.get('/v1.0/ui/images/favicon.ico') # type: flask.Response
|
||||
assert swagger_icon.status_code == 200
|
||||
|
||||
post_greeting_url = app_client.post('/v1.0/greeting/jsantos/the/third/of/his/name', data={}) # type: flask.Response
|
||||
assert post_greeting_url.status_code == 200
|
||||
assert post_greeting_url.content_type == 'application/json'
|
||||
greeting_response_url = json.loads(post_greeting_url.data.decode('utf-8'))
|
||||
assert greeting_response_url['greeting'] == 'Hello jsantos thanks for the/third/of/his/name'
|
||||
|
||||
post_greeting = app_client.post('/v1.0/greeting/jsantos', data={}) # type: flask.Response
|
||||
assert post_greeting.status_code == 200
|
||||
assert post_greeting.content_type == 'application/json'
|
||||
|
||||
@@ -38,6 +38,9 @@ def post_greeting(name, **kwargs):
|
||||
data = {'greeting': 'Hello {name}'.format(name=name)}
|
||||
return data
|
||||
|
||||
def post_greeting_url(name, remainder, **kwargs):
|
||||
data = {'greeting': 'Hello {name} thanks for {remainder}'.format(name=name,remainder=remainder)}
|
||||
return data
|
||||
|
||||
def post_goodday(name):
|
||||
data = {'greeting': 'Hello {name}'.format(name=name)}
|
||||
|
||||
23
tests/fixtures/simple/swagger.yaml
vendored
23
tests/fixtures/simple/swagger.yaml
vendored
@@ -23,7 +23,28 @@ paths:
|
||||
description: Name of the person to greet.
|
||||
required: true
|
||||
type: string
|
||||
|
||||
/greeting/{name}/{remainder}:
|
||||
post:
|
||||
summary: Generate greeting and collect the remainder of the url
|
||||
description: Generates a greeting message and includes the rest of the url.
|
||||
operationId: fakeapi.hello.post_greeting_url
|
||||
responses:
|
||||
'200':
|
||||
description: greeting response with url
|
||||
schema:
|
||||
type: object
|
||||
parameters:
|
||||
- name: name
|
||||
in: path
|
||||
description: Name of the person to greet.
|
||||
required: true
|
||||
type: string
|
||||
- name: remainder
|
||||
in: path
|
||||
description: the rest of the url
|
||||
required: true
|
||||
type: string
|
||||
format: path
|
||||
/greetings/{name}:
|
||||
get:
|
||||
summary: Generate greeting
|
||||
|
||||
@@ -9,6 +9,7 @@ def test_flaskify_path():
|
||||
assert flask_utils.flaskify_path("foo/{a}/{b}", {'a': 'integer'}) == "foo/<int:a>/<b>"
|
||||
assert flask_utils.flaskify_path("foo/{a}/{b}", {'a': 'number'}) == "foo/<float:a>/<b>"
|
||||
assert flask_utils.flaskify_path("foo/{a}/{b}", {'a': 'path'}) == "foo/<path:a>/<b>"
|
||||
assert flask_utils.flaskify_path("foo/{a}", {'a': 'path'}) == "foo/<path:a>"
|
||||
|
||||
|
||||
def test_flaskify_endpoint():
|
||||
|
||||
Reference in New Issue
Block a user