Python flask pythonic params (#2374)

* Using connexion `pythonic_params` support while keeping OpenAPI spec file correct with reference to the original spec file.

* - Add `camelCase` query parameter which shows the incorrectnes of the conversion of the OpenAPI spec file in Python server implementation(s).

* Also use `pythonic_params=True` for the `python-aiohttp` implementation.

* - Updated Python related samples.

* The unit tests must provide the correct query parameters.

* - Updated Python related samples.
This commit is contained in:
Tom Ghyselinck
2019-03-24 03:36:26 +01:00
committed by William Cheng
parent 033ab8a6f5
commit f7943257c5
27 changed files with 190 additions and 69 deletions

View File

@@ -8,5 +8,8 @@ def main():
}
specification_dir = os.path.join(os.path.dirname(__file__), 'openapi')
app = connexion.AioHttpApp(__name__, specification_dir=specification_dir, options=options)
app.add_api('openapi.yaml', arguments={'title': 'OpenAPI Petstore'}, pass_context_arg_name='request')
app.add_api('openapi.yaml',
arguments={'title': 'OpenAPI Petstore'},
pythonic_params=True,
pass_context_arg_name='request')
app.run(port=8080)

View File

@@ -161,7 +161,7 @@ paths:
tags:
- pet
x-openapi-router-controller: openapi_server.controllers.pet_controller
/pet/{pet_id}:
/pet/{petId}:
delete:
operationId: delete_pet
parameters:
@@ -171,7 +171,7 @@ paths:
type: string
- description: Pet id to delete
in: path
name: pet_id
name: petId
required: true
schema:
format: int64
@@ -194,7 +194,7 @@ paths:
parameters:
- description: ID of pet to return
in: path
name: pet_id
name: petId
required: true
schema:
format: int64
@@ -226,7 +226,7 @@ paths:
parameters:
- description: ID of pet that needs to be updated
in: path
name: pet_id
name: petId
required: true
schema:
format: int64
@@ -256,13 +256,13 @@ paths:
- pet
x-openapi-router-controller: openapi_server.controllers.pet_controller
x-codegen-request-body-name: body
/pet/{pet_id}/uploadImage:
/pet/{petId}/uploadImage:
post:
operationId: upload_file
parameters:
- description: ID of pet to update
in: path
name: pet_id
name: petId
required: true
schema:
format: int64
@@ -345,14 +345,14 @@ paths:
- store
x-codegen-request-body-name: body
x-openapi-router-controller: openapi_server.controllers.store_controller
/store/order/{order_id}:
/store/order/{orderId}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
operationId: delete_order
parameters:
- description: ID of the order that needs to be deleted
in: path
name: order_id
name: orderId
required: true
schema:
type: string
@@ -373,7 +373,7 @@ paths:
parameters:
- description: ID of pet that needs to be fetched
in: path
name: order_id
name: orderId
required: true
schema:
format: int64

View File

@@ -11,7 +11,11 @@ def client(loop, aiohttp_client):
options = {
"swagger_ui": True
}
specification_dir = os.path.join(os.path.dirname(__file__), '..', 'openapi_server', 'openapi')
app = connexion.AioHttpApp(__name__, specification_dir=specification_dir, options=options)
app.add_api('openapi.yaml', pass_context_arg_name='request')
specification_dir = os.path.join(os.path.dirname(__file__), '..',
'openapi_server',
'openapi')
app = connexion.AioHttpApp(__name__, specification_dir=specification_dir,
options=options)
app.add_api('openapi.yaml', pythonic_params=True,
pass_context_arg_name='request')
return loop.run_until_complete(aiohttp_client(app.app))