forked from loafle/openapi-generator-original
Update Python flask default value (#361)
* update python flask default value * update python flask samples
This commit is contained in:
@@ -140,7 +140,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
|||||||
regexModifiers.put('x', "VERBOSE");
|
regexModifiers.put('x', "VERBOSE");
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")
|
||||||
.defaultValue("swagger_server"));
|
.defaultValue("openapi_server"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "python package version.")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "python package version.")
|
||||||
.defaultValue("1.0.0"));
|
.defaultValue("1.0.0"));
|
||||||
cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package").
|
cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package").
|
||||||
@@ -161,7 +161,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
|||||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||||
} else {
|
} else {
|
||||||
setPackageName("swagger_server");
|
setPackageName("openapi_server");
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, this.packageName);
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, this.packageName);
|
||||||
}
|
}
|
||||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||||
@@ -315,7 +315,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
// need vendor extensions for x-swagger-router-controller
|
// need vendor extensions for x-openapi-router-controller
|
||||||
Map<String, PathItem> paths = openAPI.getPaths();
|
Map<String, PathItem> paths = openAPI.getPaths();
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (String pathname : paths.keySet()) {
|
for (String pathname : paths.keySet()) {
|
||||||
@@ -333,9 +333,9 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
|||||||
operationId = getOrGenerateOperationId(operation, pathname, method.toString());
|
operationId = getOrGenerateOperationId(operation, pathname, method.toString());
|
||||||
}
|
}
|
||||||
operation.setOperationId(toOperationId(operationId));
|
operation.setOperationId(toOperationId(operationId));
|
||||||
if (operation.getExtensions().get("x-swagger-router-controller") == null) {
|
if (operation.getExtensions().get("x-openapi-router-controller") == null) {
|
||||||
operation.addExtension(
|
operation.addExtension(
|
||||||
"x-swagger-router-controller",
|
"x-openapi-router-controller",
|
||||||
controllerPackage + "." + toApiFilename(tag)
|
controllerPackage + "." + toApiFilename(tag)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
|||||||
/**
|
/**
|
||||||
* Return the default value of the property
|
* Return the default value of the property
|
||||||
*
|
*
|
||||||
* @param p Swagger property object
|
* @param p OpenAPI property object
|
||||||
* @return string presentation of the default value of the property
|
* @return string presentation of the default value of the property
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ T = typing.TypeVar('T')
|
|||||||
|
|
||||||
|
|
||||||
class Model(object):
|
class Model(object):
|
||||||
# swaggerTypes: The key is attribute name and the
|
# openapiTypes: The key is attribute name and the
|
||||||
# value is attribute type.
|
# value is attribute type.
|
||||||
swagger_types = {}
|
openapi_types = {}
|
||||||
|
|
||||||
# attributeMap: The key is attribute name and the
|
# attributeMap: The key is attribute name and the
|
||||||
# value is json key in definition.
|
# value is json key in definition.
|
||||||
@@ -33,7 +33,7 @@ class Model(object):
|
|||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
for attr, _ in six.iteritems(self.swagger_types):
|
for attr, _ in six.iteritems(self.openapi_types):
|
||||||
value = getattr(self, attr)
|
value = getattr(self, attr)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
result[attr] = list(map(
|
result[attr] = list(map(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class JSONEncoder(FlaskJSONEncoder):
|
|||||||
def default(self, o):
|
def default(self, o):
|
||||||
if isinstance(o, Model):
|
if isinstance(o, Model):
|
||||||
dikt = {}
|
dikt = {}
|
||||||
for attr, _ in six.iteritems(o.swagger_types):
|
for attr, _ in six.iteritems(o.openapi_types):
|
||||||
value = getattr(o, attr)
|
value = getattr(o, attr)
|
||||||
if value is None and not self.include_nulls:
|
if value is None and not self.include_nulls:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ class {{classname}}(Model):
|
|||||||
{{/enumVars}}{{/allowableValues}}
|
{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
|
def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
|
||||||
"""{{classname}} - a model defined in Swagger
|
"""{{classname}} - a model defined in OpenAPI
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
||||||
:type {{name}}: {{datatype}}
|
:type {{name}}: {{datatype}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
'{{name}}': {{{datatype}}}{{#hasMore}},{{/hasMore}}
|
'{{name}}': {{{datatype}}}{{#hasMore}},{{/hasMore}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|||||||
@@ -100,10 +100,10 @@ def deserialize_model(data, klass):
|
|||||||
"""
|
"""
|
||||||
instance = klass()
|
instance = klass()
|
||||||
|
|
||||||
if not instance.swagger_types:
|
if not instance.openapi_types:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
for attr, attr_type in six.iteritems(instance.swagger_types):
|
for attr, attr_type in six.iteritems(instance.openapi_types):
|
||||||
if data is not None \
|
if data is not None \
|
||||||
and instance.attribute_map[attr] in data \
|
and instance.attribute_map[attr] in data \
|
||||||
and isinstance(data, (list, dict)):
|
and isinstance(data, (list, dict)):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.travis.yaml
|
.travis.yaml
|
||||||
.swagger-codegen-ignore
|
.openapi-generator-ignore
|
||||||
README.md
|
README.md
|
||||||
tox.ini
|
tox.ini
|
||||||
git_push.sh
|
git_push.sh
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.3.0-SNAPSHOT
|
3.0.0-SNAPSHOT
|
||||||
@@ -13,4 +13,4 @@ EXPOSE 8080
|
|||||||
|
|
||||||
ENTRYPOINT ["python"]
|
ENTRYPOINT ["python"]
|
||||||
|
|
||||||
CMD ["-m", "swagger_server"]
|
CMD ["-m", "openapi_server"]
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
# Swagger generated server
|
# OpenAPI generated server
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the
|
||||||
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
|
[OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub. This
|
||||||
is an example of building a swagger-enabled Flask server.
|
is an example of building a OpenAPI-enabled Flask server.
|
||||||
|
|
||||||
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ To run the server, please execute the following from the root directory:
|
|||||||
|
|
||||||
```
|
```
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
python -m swagger_server
|
python -m openapi_server
|
||||||
```
|
```
|
||||||
|
|
||||||
and open your browser to here:
|
and open your browser to here:
|
||||||
@@ -24,10 +24,10 @@ and open your browser to here:
|
|||||||
http://localhost:8080/v2/ui/
|
http://localhost:8080/v2/ui/
|
||||||
```
|
```
|
||||||
|
|
||||||
Your Swagger definition lives here:
|
Your OpenAPI definition lives here:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://localhost:8080/v2/swagger.json
|
http://localhost:8080/v2/openapi.json
|
||||||
```
|
```
|
||||||
|
|
||||||
To launch the integration tests, use tox:
|
To launch the integration tests, use tox:
|
||||||
@@ -42,8 +42,8 @@ To run the server on a Docker container, please execute the following from the r
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# building the image
|
# building the image
|
||||||
docker build -t swagger_server .
|
docker build -t openapi_server .
|
||||||
|
|
||||||
# starting up a container
|
# starting up a container
|
||||||
docker run -p 8080:8080 swagger_server
|
docker run -p 8080:8080 openapi_server
|
||||||
```
|
```
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
#
|
#
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||||
|
|
||||||
git_user_id=$1
|
git_user_id=$1
|
||||||
git_repo_id=$2
|
git_repo_id=$2
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
import connexion
|
import connexion
|
||||||
|
|
||||||
from swagger_server import encoder
|
from openapi_server import encoder
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = connexion.App(__name__, specification_dir='./swagger/')
|
app = connexion.App(__name__, specification_dir='./openapi/')
|
||||||
app.app.json_encoder = encoder.JSONEncoder
|
app.app.json_encoder = encoder.JSONEncoder
|
||||||
app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'})
|
app.add_api('openapi.yaml', arguments={'title': 'OpenAPI Petstore'})
|
||||||
app.run(port=8080)
|
app.run(port=8080)
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from swagger_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
def add_pet(pet): # noqa: E501
|
def add_pet(pet): # noqa: E501
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.order import Order # noqa: E501
|
from openapi_server.models.order import Order # noqa: E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
def delete_order(order_id): # noqa: E501
|
def delete_order(order_id): # noqa: E501
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.user import User # noqa: E501
|
from openapi_server.models.user import User # noqa: E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
def create_user(user): # noqa: E501
|
def create_user(user): # noqa: E501
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from connexion.apps.flask_app import FlaskJSONEncoder
|
from connexion.apps.flask_app import FlaskJSONEncoder
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
|
|
||||||
|
|
||||||
class JSONEncoder(FlaskJSONEncoder):
|
class JSONEncoder(FlaskJSONEncoder):
|
||||||
@@ -10,7 +10,7 @@ class JSONEncoder(FlaskJSONEncoder):
|
|||||||
def default(self, o):
|
def default(self, o):
|
||||||
if isinstance(o, Model):
|
if isinstance(o, Model):
|
||||||
dikt = {}
|
dikt = {}
|
||||||
for attr, _ in six.iteritems(o.swagger_types):
|
for attr, _ in six.iteritems(o.openapi_types):
|
||||||
value = getattr(o, attr)
|
value = getattr(o, attr)
|
||||||
if value is None and not self.include_nulls:
|
if value is None and not self.include_nulls:
|
||||||
continue
|
continue
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
# flake8: noqa
|
||||||
|
from __future__ import absolute_import
|
||||||
|
# import models into model package
|
||||||
|
from openapi_server.models.api_response import ApiResponse
|
||||||
|
from openapi_server.models.category import Category
|
||||||
|
from openapi_server.models.order import Order
|
||||||
|
from openapi_server.models.pet import Pet
|
||||||
|
from openapi_server.models.tag import Tag
|
||||||
|
from openapi_server.models.user import User
|
||||||
@@ -5,18 +5,18 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class ApiResponse(Model):
|
class ApiResponse(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, code=None, type=None, message=None): # noqa: E501
|
def __init__(self, code=None, type=None, message=None): # noqa: E501
|
||||||
"""ApiResponse - a model defined in Swagger
|
"""ApiResponse - a model defined in OpenAPI
|
||||||
|
|
||||||
:param code: The code of this ApiResponse. # noqa: E501
|
:param code: The code of this ApiResponse. # noqa: E501
|
||||||
:type code: int
|
:type code: int
|
||||||
@@ -25,7 +25,7 @@ class ApiResponse(Model):
|
|||||||
:param message: The message of this ApiResponse. # noqa: E501
|
:param message: The message of this ApiResponse. # noqa: E501
|
||||||
:type message: str
|
:type message: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'code': int,
|
'code': int,
|
||||||
'type': str,
|
'type': str,
|
||||||
'message': str
|
'message': str
|
||||||
@@ -2,13 +2,13 @@ import pprint
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Model(object):
|
class Model(object):
|
||||||
# swaggerTypes: The key is attribute name and the
|
# openapiTypes: The key is attribute name and the
|
||||||
# value is attribute type.
|
# value is attribute type.
|
||||||
swagger_types = {}
|
openapi_types = {}
|
||||||
|
|
||||||
# attributeMap: The key is attribute name and the
|
# attributeMap: The key is attribute name and the
|
||||||
# value is json key in definition.
|
# value is json key in definition.
|
||||||
@@ -26,7 +26,7 @@ class Model(object):
|
|||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
for attr, _ in six.iteritems(self.swagger_types):
|
for attr, _ in six.iteritems(self.openapi_types):
|
||||||
value = getattr(self, attr)
|
value = getattr(self, attr)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
result[attr] = list(map(
|
result[attr] = list(map(
|
||||||
@@ -5,25 +5,25 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Category(Model):
|
class Category(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id=None, name=None): # noqa: E501
|
def __init__(self, id=None, name=None): # noqa: E501
|
||||||
"""Category - a model defined in Swagger
|
"""Category - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Category. # noqa: E501
|
:param id: The id of this Category. # noqa: E501
|
||||||
:type id: long
|
:type id: long
|
||||||
:param name: The name of this Category. # noqa: E501
|
:param name: The name of this Category. # noqa: E501
|
||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': long,
|
'id': long,
|
||||||
'name': str
|
'name': str
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,18 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Order(Model):
|
class Order(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): # noqa: E501
|
def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): # noqa: E501
|
||||||
"""Order - a model defined in Swagger
|
"""Order - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Order. # noqa: E501
|
:param id: The id of this Order. # noqa: E501
|
||||||
:type id: long
|
:type id: long
|
||||||
@@ -31,7 +31,7 @@ class Order(Model):
|
|||||||
:param complete: The complete of this Order. # noqa: E501
|
:param complete: The complete of this Order. # noqa: E501
|
||||||
:type complete: bool
|
:type complete: bool
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': long,
|
'id': long,
|
||||||
'pet_id': long,
|
'pet_id': long,
|
||||||
'quantity': int,
|
'quantity': int,
|
||||||
@@ -5,20 +5,20 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server.models.category import Category # noqa: F401,E501
|
from openapi_server.models.category import Category # noqa: F401,E501
|
||||||
from swagger_server.models.tag import Tag # noqa: F401,E501
|
from openapi_server.models.tag import Tag # noqa: F401,E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Pet(Model):
|
class Pet(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): # noqa: E501
|
def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): # noqa: E501
|
||||||
"""Pet - a model defined in Swagger
|
"""Pet - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Pet. # noqa: E501
|
:param id: The id of this Pet. # noqa: E501
|
||||||
:type id: long
|
:type id: long
|
||||||
@@ -33,7 +33,7 @@ class Pet(Model):
|
|||||||
:param status: The status of this Pet. # noqa: E501
|
:param status: The status of this Pet. # noqa: E501
|
||||||
:type status: str
|
:type status: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': long,
|
'id': long,
|
||||||
'category': Category,
|
'category': Category,
|
||||||
'name': str,
|
'name': str,
|
||||||
@@ -5,25 +5,25 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Tag(Model):
|
class Tag(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id=None, name=None): # noqa: E501
|
def __init__(self, id=None, name=None): # noqa: E501
|
||||||
"""Tag - a model defined in Swagger
|
"""Tag - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Tag. # noqa: E501
|
:param id: The id of this Tag. # noqa: E501
|
||||||
:type id: long
|
:type id: long
|
||||||
:param name: The name of this Tag. # noqa: E501
|
:param name: The name of this Tag. # noqa: E501
|
||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': long,
|
'id': long,
|
||||||
'name': str
|
'name': str
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,18 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class User(Model):
|
class User(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501
|
def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501
|
||||||
"""User - a model defined in Swagger
|
"""User - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this User. # noqa: E501
|
:param id: The id of this User. # noqa: E501
|
||||||
:type id: long
|
:type id: long
|
||||||
@@ -35,7 +35,7 @@ class User(Model):
|
|||||||
:param user_status: The user_status of this User. # noqa: E501
|
:param user_status: The user_status of this User. # noqa: E501
|
||||||
:type user_status: int
|
:type user_status: int
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': long,
|
'id': long,
|
||||||
'username': str,
|
'username': str,
|
||||||
'first_name': str,
|
'first_name': str,
|
||||||
@@ -1,34 +1,20 @@
|
|||||||
openapi: 3.0.1
|
openapi: 3.0.1
|
||||||
info:
|
info:
|
||||||
title: Swagger Petstore
|
title: OpenAPI Petstore
|
||||||
description: 'This is a sample server Petstore server. You can find out more about
|
description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For
|
|
||||||
this sample, you can use the api key `special-key` to test the authorization filters.'
|
|
||||||
termsOfService: http://swagger.io/terms/
|
|
||||||
contact:
|
|
||||||
email: apiteam@swagger.io
|
|
||||||
license:
|
license:
|
||||||
name: Apache-2.0
|
name: Apache-2.0
|
||||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
externalDocs:
|
|
||||||
description: Find out more about Swagger
|
|
||||||
url: http://swagger.io
|
|
||||||
servers:
|
servers:
|
||||||
- url: http://petstore.swagger.io/v2
|
- url: http://petstore.swagger.io/v2
|
||||||
tags:
|
tags:
|
||||||
- name: pet
|
- name: pet
|
||||||
description: Everything about your Pets
|
description: Everything about your Pets
|
||||||
externalDocs:
|
|
||||||
description: Find out more
|
|
||||||
url: http://swagger.io
|
|
||||||
- name: store
|
- name: store
|
||||||
description: Access to Petstore orders
|
description: Access to Petstore orders
|
||||||
- name: user
|
- name: user
|
||||||
description: Operations about user
|
description: Operations about user
|
||||||
externalDocs:
|
|
||||||
description: Find out more about our store
|
|
||||||
url: http://swagger.io
|
|
||||||
paths:
|
paths:
|
||||||
/pet:
|
/pet:
|
||||||
put:
|
put:
|
||||||
@@ -60,7 +46,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
@@ -84,7 +70,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
/pet/findByStatus:
|
/pet/findByStatus:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -128,7 +114,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
/pet/findByTags:
|
/pet/findByTags:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -168,7 +154,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
/pet/{petId}:
|
/pet/{petId}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -202,7 +188,7 @@ paths:
|
|||||||
content: {}
|
content: {}
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
@@ -235,7 +221,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
@@ -261,7 +247,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
/pet/{petId}/uploadImage:
|
/pet/{petId}/uploadImage:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -299,7 +285,7 @@ paths:
|
|||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write:pets
|
- write:pets
|
||||||
- read:pets
|
- read:pets
|
||||||
x-swagger-router-controller: swagger_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
/store/inventory:
|
/store/inventory:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -319,7 +305,7 @@ paths:
|
|||||||
format: int32
|
format: int32
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
x-swagger-router-controller: swagger_server.controllers.store_controller
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
/store/order:
|
/store/order:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -346,7 +332,7 @@ paths:
|
|||||||
400:
|
400:
|
||||||
description: Invalid Order
|
description: Invalid Order
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.store_controller
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
/store/order/{orderId}:
|
/store/order/{orderId}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -380,7 +366,7 @@ paths:
|
|||||||
404:
|
404:
|
||||||
description: Order not found
|
description: Order not found
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.store_controller
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- store
|
- store
|
||||||
@@ -401,7 +387,7 @@ paths:
|
|||||||
404:
|
404:
|
||||||
description: Order not found
|
description: Order not found
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.store_controller
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
/user:
|
/user:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -420,7 +406,7 @@ paths:
|
|||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
/user/createWithArray:
|
/user/createWithArray:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -440,7 +426,7 @@ paths:
|
|||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
/user/createWithList:
|
/user/createWithList:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -460,7 +446,7 @@ paths:
|
|||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
/user/login:
|
/user/login:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -504,7 +490,7 @@ paths:
|
|||||||
400:
|
400:
|
||||||
description: Invalid username/password supplied
|
description: Invalid username/password supplied
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
/user/logout:
|
/user/logout:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -515,7 +501,7 @@ paths:
|
|||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
/user/{username}:
|
/user/{username}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -545,7 +531,7 @@ paths:
|
|||||||
404:
|
404:
|
||||||
description: User not found
|
description: User not found
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
put:
|
put:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
@@ -573,7 +559,7 @@ paths:
|
|||||||
404:
|
404:
|
||||||
description: User not found
|
description: User not found
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
@@ -594,7 +580,7 @@ paths:
|
|||||||
404:
|
404:
|
||||||
description: User not found
|
description: User not found
|
||||||
content: {}
|
content: {}
|
||||||
x-swagger-router-controller: swagger_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
Order:
|
Order:
|
||||||
@@ -624,6 +610,13 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
description: An order for a pets from the pet store
|
description: An order for a pets from the pet store
|
||||||
|
example:
|
||||||
|
petId: 6
|
||||||
|
quantity: 1
|
||||||
|
id: 0
|
||||||
|
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||||
|
complete: false
|
||||||
|
status: placed
|
||||||
xml:
|
xml:
|
||||||
name: Order
|
name: Order
|
||||||
Category:
|
Category:
|
||||||
@@ -636,6 +629,9 @@ components:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
description: A category for a pet
|
description: A category for a pet
|
||||||
|
example:
|
||||||
|
name: name
|
||||||
|
id: 6
|
||||||
xml:
|
xml:
|
||||||
name: Category
|
name: Category
|
||||||
User:
|
User:
|
||||||
@@ -662,6 +658,15 @@ components:
|
|||||||
description: User Status
|
description: User Status
|
||||||
format: int32
|
format: int32
|
||||||
description: A User who is purchasing from the pet store
|
description: A User who is purchasing from the pet store
|
||||||
|
example:
|
||||||
|
firstName: firstName
|
||||||
|
lastName: lastName
|
||||||
|
password: password
|
||||||
|
userStatus: 6
|
||||||
|
phone: phone
|
||||||
|
id: 0
|
||||||
|
email: email
|
||||||
|
username: username
|
||||||
xml:
|
xml:
|
||||||
name: User
|
name: User
|
||||||
Tag:
|
Tag:
|
||||||
@@ -674,6 +679,9 @@ components:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
description: A tag for a pet
|
description: A tag for a pet
|
||||||
|
example:
|
||||||
|
name: name
|
||||||
|
id: 1
|
||||||
xml:
|
xml:
|
||||||
name: Tag
|
name: Tag
|
||||||
Pet:
|
Pet:
|
||||||
@@ -713,6 +721,21 @@ components:
|
|||||||
- pending
|
- pending
|
||||||
- sold
|
- sold
|
||||||
description: A pet for sale in the pet store
|
description: A pet for sale in the pet store
|
||||||
|
example:
|
||||||
|
photoUrls:
|
||||||
|
- photoUrls
|
||||||
|
- photoUrls
|
||||||
|
name: doggie
|
||||||
|
id: 0
|
||||||
|
category:
|
||||||
|
name: name
|
||||||
|
id: 6
|
||||||
|
tags:
|
||||||
|
- name: name
|
||||||
|
id: 1
|
||||||
|
- name: name
|
||||||
|
id: 1
|
||||||
|
status: available
|
||||||
xml:
|
xml:
|
||||||
name: Pet
|
name: Pet
|
||||||
ApiResponse:
|
ApiResponse:
|
||||||
@@ -727,6 +750,10 @@ components:
|
|||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
description: Describes the result of uploading an image resource
|
description: Describes the result of uploading an image resource
|
||||||
|
example:
|
||||||
|
code: 0
|
||||||
|
type: type
|
||||||
|
message: message
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
petstore_auth:
|
petstore_auth:
|
||||||
type: oauth2
|
type: oauth2
|
||||||
@@ -3,7 +3,7 @@ import logging
|
|||||||
import connexion
|
import connexion
|
||||||
from flask_testing import TestCase
|
from flask_testing import TestCase
|
||||||
|
|
||||||
from swagger_server.encoder import JSONEncoder
|
from openapi_server.encoder import JSONEncoder
|
||||||
|
|
||||||
|
|
||||||
class BaseTestCase(TestCase):
|
class BaseTestCase(TestCase):
|
||||||
@@ -5,9 +5,9 @@ from __future__ import absolute_import
|
|||||||
from flask import json
|
from flask import json
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
|
|
||||||
from swagger_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from swagger_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
from swagger_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestPetController(BaseTestCase):
|
class TestPetController(BaseTestCase):
|
||||||
@@ -5,8 +5,8 @@ from __future__ import absolute_import
|
|||||||
from flask import json
|
from flask import json
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
|
|
||||||
from swagger_server.models.order import Order # noqa: E501
|
from openapi_server.models.order import Order # noqa: E501
|
||||||
from swagger_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestStoreController(BaseTestCase):
|
class TestStoreController(BaseTestCase):
|
||||||
@@ -55,7 +55,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
'/v2/store/order',
|
'/v2/store/order',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(order),
|
data=json.dumps(order),
|
||||||
content_type='*/*')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@@ -5,8 +5,8 @@ from __future__ import absolute_import
|
|||||||
from flask import json
|
from flask import json
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
|
|
||||||
from swagger_server.models.user import User # noqa: E501
|
from openapi_server.models.user import User # noqa: E501
|
||||||
from swagger_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestUserController(BaseTestCase):
|
class TestUserController(BaseTestCase):
|
||||||
@@ -22,7 +22,7 @@ class TestUserController(BaseTestCase):
|
|||||||
'/v2/user',
|
'/v2/user',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(user),
|
data=json.dumps(user),
|
||||||
content_type='*/*')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@@ -31,12 +31,12 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
user = [User()]
|
user = None
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/createWithArray',
|
'/v2/user/createWithArray',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(user),
|
data=json.dumps(user),
|
||||||
content_type='*/*')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@@ -45,12 +45,12 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
user = [User()]
|
user = None
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/createWithList',
|
'/v2/user/createWithList',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(user),
|
data=json.dumps(user),
|
||||||
content_type='*/*')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ class TestUserController(BaseTestCase):
|
|||||||
'/v2/user/{username}'.format(username='username_example'),
|
'/v2/user/{username}'.format(username='username_example'),
|
||||||
method='PUT',
|
method='PUT',
|
||||||
data=json.dumps(user),
|
data=json.dumps(user),
|
||||||
content_type='*/*')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@@ -100,10 +100,10 @@ def deserialize_model(data, klass):
|
|||||||
"""
|
"""
|
||||||
instance = klass()
|
instance = klass()
|
||||||
|
|
||||||
if not instance.swagger_types:
|
if not instance.openapi_types:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
for attr, attr_type in six.iteritems(instance.swagger_types):
|
for attr, attr_type in six.iteritems(instance.openapi_types):
|
||||||
if data is not None \
|
if data is not None \
|
||||||
and instance.attribute_map[attr] in data \
|
and instance.attribute_map[attr] in data \
|
||||||
and isinstance(data, (list, dict)):
|
and isinstance(data, (list, dict)):
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
NAME = "swagger_server"
|
NAME = "openapi_server"
|
||||||
VERSION = "1.0.0"
|
VERSION = "1.0.0"
|
||||||
|
|
||||||
# To install the library, run the following
|
# To install the library, run the following
|
||||||
@@ -18,18 +18,18 @@ REQUIRES = ["connexion"]
|
|||||||
setup(
|
setup(
|
||||||
name=NAME,
|
name=NAME,
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
description="Swagger Petstore",
|
description="OpenAPI Petstore",
|
||||||
author_email="apiteam@swagger.io",
|
author_email="",
|
||||||
url="",
|
url="",
|
||||||
keywords=["Swagger", "Swagger Petstore"],
|
keywords=["OpenAPI", "OpenAPI Petstore"],
|
||||||
install_requires=REQUIRES,
|
install_requires=REQUIRES,
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
package_data={'': ['swagger/swagger.yaml']},
|
package_data={'': ['openapi/openapi.yaml']},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': ['swagger_server=swagger_server.__main__:main']},
|
'console_scripts': ['openapi_server=openapi_server.__main__:main']},
|
||||||
long_description="""\
|
long_description="""\
|
||||||
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
|
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# coding: utf-8
|
|
||||||
|
|
||||||
# flake8: noqa
|
|
||||||
from __future__ import absolute_import
|
|
||||||
# import models into model package
|
|
||||||
from swagger_server.models.api_response import ApiResponse
|
|
||||||
from swagger_server.models.category import Category
|
|
||||||
from swagger_server.models.order import Order
|
|
||||||
from swagger_server.models.pet import Pet
|
|
||||||
from swagger_server.models.tag import Tag
|
|
||||||
from swagger_server.models.user import User
|
|
||||||
@@ -1,775 +0,0 @@
|
|||||||
---
|
|
||||||
swagger: "2.0"
|
|
||||||
info:
|
|
||||||
description: "This is a sample server Petstore server. You can find out more about\
|
|
||||||
\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\
|
|
||||||
\ For this sample, you can use the api key `special-key` to test the authorization\
|
|
||||||
\ filters."
|
|
||||||
version: "1.0.0"
|
|
||||||
title: "Swagger Petstore"
|
|
||||||
termsOfService: "http://swagger.io/terms/"
|
|
||||||
contact:
|
|
||||||
email: "apiteam@swagger.io"
|
|
||||||
license:
|
|
||||||
name: "Apache-2.0"
|
|
||||||
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
|
||||||
host: "petstore.swagger.io"
|
|
||||||
basePath: "/v2"
|
|
||||||
tags:
|
|
||||||
- name: "pet"
|
|
||||||
description: "Everything about your Pets"
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
- name: "store"
|
|
||||||
description: "Access to Petstore orders"
|
|
||||||
- name: "user"
|
|
||||||
description: "Operations about user"
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more about our store"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
schemes:
|
|
||||||
- "http"
|
|
||||||
paths:
|
|
||||||
/pet:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Add a new pet to the store"
|
|
||||||
description: ""
|
|
||||||
operationId: "add_pet"
|
|
||||||
consumes:
|
|
||||||
- "application/json"
|
|
||||||
- "application/xml"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Pet object that needs to be added to the store"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: "Invalid input"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
put:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Update an existing pet"
|
|
||||||
description: ""
|
|
||||||
operationId: "update_pet"
|
|
||||||
consumes:
|
|
||||||
- "application/json"
|
|
||||||
- "application/xml"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Pet object that needs to be added to the store"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Pet not found"
|
|
||||||
405:
|
|
||||||
description: "Validation exception"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
/pet/findByStatus:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Finds Pets by status"
|
|
||||||
description: "Multiple status values can be provided with comma separated strings"
|
|
||||||
operationId: "find_pets_by_status"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "status"
|
|
||||||
in: "query"
|
|
||||||
description: "Status values that need to be considered for filter"
|
|
||||||
required: true
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
default: "available"
|
|
||||||
enum:
|
|
||||||
- "available"
|
|
||||||
- "pending"
|
|
||||||
- "sold"
|
|
||||||
collectionFormat: "csv"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
400:
|
|
||||||
description: "Invalid status value"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
/pet/findByTags:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Finds Pets by tags"
|
|
||||||
description: "Multiple tags can be provided with comma separated strings. Use\
|
|
||||||
\ tag1, tag2, tag3 for testing."
|
|
||||||
operationId: "find_pets_by_tags"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "tags"
|
|
||||||
in: "query"
|
|
||||||
description: "Tags to filter by"
|
|
||||||
required: true
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
collectionFormat: "csv"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
400:
|
|
||||||
description: "Invalid tag value"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
deprecated: true
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
/pet/{petId}:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Find pet by ID"
|
|
||||||
description: "Returns a single pet"
|
|
||||||
operationId: "get_pet_by_id"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet to return"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Pet not found"
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Updates a pet in the store with form data"
|
|
||||||
description: ""
|
|
||||||
operationId: "update_pet_with_form"
|
|
||||||
consumes:
|
|
||||||
- "application/x-www-form-urlencoded"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet that needs to be updated"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
- name: "name"
|
|
||||||
in: "formData"
|
|
||||||
description: "Updated name of the pet"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
- name: "status"
|
|
||||||
in: "formData"
|
|
||||||
description: "Updated status of the pet"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: "Invalid input"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
delete:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Deletes a pet"
|
|
||||||
description: ""
|
|
||||||
operationId: "delete_pet"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "api_key"
|
|
||||||
in: "header"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "Pet id to delete"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid pet value"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
/pet/{petId}/uploadImage:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "uploads an image"
|
|
||||||
description: ""
|
|
||||||
operationId: "upload_file"
|
|
||||||
consumes:
|
|
||||||
- "multipart/form-data"
|
|
||||||
produces:
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet to update"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
- name: "additionalMetadata"
|
|
||||||
in: "formData"
|
|
||||||
description: "Additional data to pass to server"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
- name: "file"
|
|
||||||
in: "formData"
|
|
||||||
description: "file to upload"
|
|
||||||
required: false
|
|
||||||
type: "file"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/ApiResponse"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.pet_controller"
|
|
||||||
/store/inventory:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "store"
|
|
||||||
summary: "Returns pet inventories by status"
|
|
||||||
description: "Returns a map of status codes to quantities"
|
|
||||||
operationId: "get_inventory"
|
|
||||||
produces:
|
|
||||||
- "application/json"
|
|
||||||
parameters: []
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "object"
|
|
||||||
additionalProperties:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.store_controller"
|
|
||||||
/store/order:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "store"
|
|
||||||
summary: "Place an order for a pet"
|
|
||||||
description: ""
|
|
||||||
operationId: "place_order"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "order placed for purchasing the pet"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Order"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Order"
|
|
||||||
400:
|
|
||||||
description: "Invalid Order"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.store_controller"
|
|
||||||
/store/order/{orderId}:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "store"
|
|
||||||
summary: "Find purchase order by ID"
|
|
||||||
description: "For valid response try integer IDs with value <= 5 or > 10. Other\
|
|
||||||
\ values will generated exceptions"
|
|
||||||
operationId: "get_order_by_id"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "orderId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet that needs to be fetched"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
maximum: 5
|
|
||||||
minimum: 1
|
|
||||||
format: "int64"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Order"
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Order not found"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.store_controller"
|
|
||||||
delete:
|
|
||||||
tags:
|
|
||||||
- "store"
|
|
||||||
summary: "Delete purchase order by ID"
|
|
||||||
description: "For valid response try integer IDs with value < 1000. Anything\
|
|
||||||
\ above 1000 or nonintegers will generate API errors"
|
|
||||||
operationId: "delete_order"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "orderId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of the order that needs to be deleted"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Order not found"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.store_controller"
|
|
||||||
/user:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Create user"
|
|
||||||
description: "This can only be done by the logged in user."
|
|
||||||
operationId: "create_user"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Created user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
/user/createWithArray:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Creates list of users with given input array"
|
|
||||||
description: ""
|
|
||||||
operationId: "create_users_with_array_input"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "List of user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
/user/createWithList:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Creates list of users with given input array"
|
|
||||||
description: ""
|
|
||||||
operationId: "create_users_with_list_input"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "List of user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
/user/login:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Logs user into the system"
|
|
||||||
description: ""
|
|
||||||
operationId: "login_user"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "query"
|
|
||||||
description: "The user name for login"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
- name: "password"
|
|
||||||
in: "query"
|
|
||||||
description: "The password for login in clear text"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "string"
|
|
||||||
headers:
|
|
||||||
X-Rate-Limit:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
description: "calls per hour allowed by the user"
|
|
||||||
X-Expires-After:
|
|
||||||
type: "string"
|
|
||||||
format: "date-time"
|
|
||||||
description: "date in UTC when toekn expires"
|
|
||||||
400:
|
|
||||||
description: "Invalid username/password supplied"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
/user/logout:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Logs out current logged in user session"
|
|
||||||
description: ""
|
|
||||||
operationId: "logout_user"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters: []
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
/user/{username}:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Get user by user name"
|
|
||||||
description: ""
|
|
||||||
operationId: "get_user_by_name"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "path"
|
|
||||||
description: "The name that needs to be fetched. Use user1 for testing. "
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
400:
|
|
||||||
description: "Invalid username supplied"
|
|
||||||
404:
|
|
||||||
description: "User not found"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
put:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Updated user"
|
|
||||||
description: "This can only be done by the logged in user."
|
|
||||||
operationId: "update_user"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "path"
|
|
||||||
description: "name that need to be deleted"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Updated user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid user supplied"
|
|
||||||
404:
|
|
||||||
description: "User not found"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
delete:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Delete user"
|
|
||||||
description: "This can only be done by the logged in user."
|
|
||||||
operationId: "delete_user"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "path"
|
|
||||||
description: "The name that needs to be deleted"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid username supplied"
|
|
||||||
404:
|
|
||||||
description: "User not found"
|
|
||||||
x-swagger-router-controller: "swagger_server.controllers.user_controller"
|
|
||||||
securityDefinitions:
|
|
||||||
petstore_auth:
|
|
||||||
type: "oauth2"
|
|
||||||
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
|
|
||||||
flow: "implicit"
|
|
||||||
scopes:
|
|
||||||
write:pets: "modify pets in your account"
|
|
||||||
read:pets: "read your pets"
|
|
||||||
api_key:
|
|
||||||
type: "apiKey"
|
|
||||||
name: "api_key"
|
|
||||||
in: "header"
|
|
||||||
definitions:
|
|
||||||
Order:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
petId:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
quantity:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
shipDate:
|
|
||||||
type: "string"
|
|
||||||
format: "date-time"
|
|
||||||
status:
|
|
||||||
type: "string"
|
|
||||||
description: "Order Status"
|
|
||||||
enum:
|
|
||||||
- "placed"
|
|
||||||
- "approved"
|
|
||||||
- "delivered"
|
|
||||||
complete:
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
title: "Pet Order"
|
|
||||||
description: "An order for a pets from the pet store"
|
|
||||||
example:
|
|
||||||
petId: 6
|
|
||||||
quantity: 1
|
|
||||||
id: 0
|
|
||||||
shipDate: "2000-01-23T04:56:07.000+00:00"
|
|
||||||
complete: false
|
|
||||||
status: "placed"
|
|
||||||
xml:
|
|
||||||
name: "Order"
|
|
||||||
Category:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
name:
|
|
||||||
type: "string"
|
|
||||||
title: "Pet category"
|
|
||||||
description: "A category for a pet"
|
|
||||||
example:
|
|
||||||
name: "name"
|
|
||||||
id: 6
|
|
||||||
xml:
|
|
||||||
name: "Category"
|
|
||||||
User:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
username:
|
|
||||||
type: "string"
|
|
||||||
firstName:
|
|
||||||
type: "string"
|
|
||||||
lastName:
|
|
||||||
type: "string"
|
|
||||||
email:
|
|
||||||
type: "string"
|
|
||||||
password:
|
|
||||||
type: "string"
|
|
||||||
phone:
|
|
||||||
type: "string"
|
|
||||||
userStatus:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
description: "User Status"
|
|
||||||
title: "a User"
|
|
||||||
description: "A User who is purchasing from the pet store"
|
|
||||||
example:
|
|
||||||
firstName: "firstName"
|
|
||||||
lastName: "lastName"
|
|
||||||
password: "password"
|
|
||||||
userStatus: 6
|
|
||||||
phone: "phone"
|
|
||||||
id: 0
|
|
||||||
email: "email"
|
|
||||||
username: "username"
|
|
||||||
xml:
|
|
||||||
name: "User"
|
|
||||||
Tag:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
name:
|
|
||||||
type: "string"
|
|
||||||
title: "Pet Tag"
|
|
||||||
description: "A tag for a pet"
|
|
||||||
example:
|
|
||||||
name: "name"
|
|
||||||
id: 1
|
|
||||||
xml:
|
|
||||||
name: "Tag"
|
|
||||||
Pet:
|
|
||||||
type: "object"
|
|
||||||
required:
|
|
||||||
- "name"
|
|
||||||
- "photoUrls"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
category:
|
|
||||||
$ref: "#/definitions/Category"
|
|
||||||
name:
|
|
||||||
type: "string"
|
|
||||||
example: "doggie"
|
|
||||||
photoUrls:
|
|
||||||
type: "array"
|
|
||||||
xml:
|
|
||||||
name: "photoUrl"
|
|
||||||
wrapped: true
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
tags:
|
|
||||||
type: "array"
|
|
||||||
xml:
|
|
||||||
name: "tag"
|
|
||||||
wrapped: true
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Tag"
|
|
||||||
status:
|
|
||||||
type: "string"
|
|
||||||
description: "pet status in the store"
|
|
||||||
enum:
|
|
||||||
- "available"
|
|
||||||
- "pending"
|
|
||||||
- "sold"
|
|
||||||
title: "a Pet"
|
|
||||||
description: "A pet for sale in the pet store"
|
|
||||||
example:
|
|
||||||
photoUrls:
|
|
||||||
- "photoUrls"
|
|
||||||
- "photoUrls"
|
|
||||||
name: "doggie"
|
|
||||||
id: 0
|
|
||||||
category:
|
|
||||||
name: "name"
|
|
||||||
id: 6
|
|
||||||
tags:
|
|
||||||
- name: "name"
|
|
||||||
id: 1
|
|
||||||
- name: "name"
|
|
||||||
id: 1
|
|
||||||
status: "available"
|
|
||||||
xml:
|
|
||||||
name: "Pet"
|
|
||||||
ApiResponse:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
type:
|
|
||||||
type: "string"
|
|
||||||
message:
|
|
||||||
type: "string"
|
|
||||||
title: "An uploaded response"
|
|
||||||
description: "Describes the result of uploading an image resource"
|
|
||||||
example:
|
|
||||||
code: 0
|
|
||||||
type: "type"
|
|
||||||
message: "message"
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more about Swagger"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
.travis.yaml
|
.travis.yaml
|
||||||
.swagger-codegen-ignore
|
.openapi-generator-ignore
|
||||||
README.md
|
README.md
|
||||||
tox.ini
|
tox.ini
|
||||||
git_push.sh
|
git_push.sh
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ EXPOSE 8080
|
|||||||
|
|
||||||
ENTRYPOINT ["python3"]
|
ENTRYPOINT ["python3"]
|
||||||
|
|
||||||
CMD ["-m", "swagger_server"]
|
CMD ["-m", "openapi_server"]
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
# Swagger generated server
|
# OpenAPI generated server
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the
|
||||||
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
|
[OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub. This
|
||||||
is an example of building a swagger-enabled Flask server.
|
is an example of building a OpenAPI-enabled Flask server.
|
||||||
|
|
||||||
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ To run the server, please execute the following from the root directory:
|
|||||||
|
|
||||||
```
|
```
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
python3 -m swagger_server
|
python3 -m openapi_server
|
||||||
```
|
```
|
||||||
|
|
||||||
and open your browser to here:
|
and open your browser to here:
|
||||||
@@ -24,7 +24,7 @@ and open your browser to here:
|
|||||||
http://localhost:8080/v2/ui/
|
http://localhost:8080/v2/ui/
|
||||||
```
|
```
|
||||||
|
|
||||||
Your Swagger definition lives here:
|
Your OpenAPI definition lives here:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://localhost:8080/v2/openapi.json
|
http://localhost:8080/v2/openapi.json
|
||||||
@@ -42,8 +42,8 @@ To run the server on a Docker container, please execute the following from the r
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# building the image
|
# building the image
|
||||||
docker build -t swagger_server .
|
docker build -t openapi_server .
|
||||||
|
|
||||||
# starting up a container
|
# starting up a container
|
||||||
docker run -p 8080:8080 swagger_server
|
docker run -p 8080:8080 openapi_server
|
||||||
```
|
```
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
#
|
#
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||||
|
|
||||||
git_user_id=$1
|
git_user_id=$1
|
||||||
git_repo_id=$2
|
git_repo_id=$2
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
import connexion
|
import connexion
|
||||||
|
|
||||||
from swagger_server import encoder
|
from openapi_server import encoder
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = connexion.App(__name__, specification_dir='./openapi/')
|
app = connexion.App(__name__, specification_dir='./openapi/')
|
||||||
app.app.json_encoder = encoder.JSONEncoder
|
app.app.json_encoder = encoder.JSONEncoder
|
||||||
app.add_api('openapi.yaml', arguments={'title': 'Swagger Petstore'})
|
app.add_api('openapi.yaml', arguments={'title': 'OpenAPI Petstore'})
|
||||||
app.run(port=8080)
|
app.run(port=8080)
|
||||||
|
|
||||||
|
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from swagger_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
def add_pet(body): # noqa: E501
|
def add_pet(pet): # noqa: E501
|
||||||
"""Add a new pet to the store
|
"""Add a new pet to the store
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param body: Pet object that needs to be added to the store
|
:param pet: Pet object that needs to be added to the store
|
||||||
:type body: dict | bytes
|
:type pet: dict | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
|
pet = Pet.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def delete_pet(petId, api_key=None): # noqa: E501
|
def delete_pet(pet_id, api_key=None): # noqa: E501
|
||||||
"""Deletes a pet
|
"""Deletes a pet
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param petId: Pet id to delete
|
:param pet_id: Pet id to delete
|
||||||
:type petId: int
|
:type pet_id: int
|
||||||
:param api_key:
|
:param api_key:
|
||||||
:type api_key: str
|
:type api_key: str
|
||||||
|
|
||||||
@@ -62,41 +62,41 @@ def find_pets_by_tags(tags): # noqa: E501
|
|||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def get_pet_by_id(petId): # noqa: E501
|
def get_pet_by_id(pet_id): # noqa: E501
|
||||||
"""Find pet by ID
|
"""Find pet by ID
|
||||||
|
|
||||||
Returns a single pet # noqa: E501
|
Returns a single pet # noqa: E501
|
||||||
|
|
||||||
:param petId: ID of pet to return
|
:param pet_id: ID of pet to return
|
||||||
:type petId: int
|
:type pet_id: int
|
||||||
|
|
||||||
:rtype: Pet
|
:rtype: Pet
|
||||||
"""
|
"""
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def update_pet(body): # noqa: E501
|
def update_pet(pet): # noqa: E501
|
||||||
"""Update an existing pet
|
"""Update an existing pet
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param body: Pet object that needs to be added to the store
|
:param pet: Pet object that needs to be added to the store
|
||||||
:type body: dict | bytes
|
:type pet: dict | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
|
pet = Pet.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def update_pet_with_form(petId, name=None, status=None): # noqa: E501
|
def update_pet_with_form(pet_id, name=None, status=None): # noqa: E501
|
||||||
"""Updates a pet in the store with form data
|
"""Updates a pet in the store with form data
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param petId: ID of pet that needs to be updated
|
:param pet_id: ID of pet that needs to be updated
|
||||||
:type petId: int
|
:type pet_id: int
|
||||||
:param name: Updated name of the pet
|
:param name: Updated name of the pet
|
||||||
:type name: str
|
:type name: str
|
||||||
:param status: Updated status of the pet
|
:param status: Updated status of the pet
|
||||||
@@ -107,17 +107,17 @@ def update_pet_with_form(petId, name=None, status=None): # noqa: E501
|
|||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def upload_file(petId, additionalMetadata=None, file=None): # noqa: E501
|
def upload_file(pet_id, additional_metadata=None, file=None): # noqa: E501
|
||||||
"""uploads an image
|
"""uploads an image
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param petId: ID of pet to update
|
:param pet_id: ID of pet to update
|
||||||
:type petId: int
|
:type pet_id: int
|
||||||
:param additionalMetadata: Additional data to pass to server
|
:param additional_metadata: Additional data to pass to server
|
||||||
:type additionalMetadata: str
|
:type additional_metadata: str
|
||||||
:param file: file to upload
|
:param file: file to upload
|
||||||
:type file: werkzeug.datastructures.FileStorage
|
:type file: str
|
||||||
|
|
||||||
:rtype: ApiResponse
|
:rtype: ApiResponse
|
||||||
"""
|
"""
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.order import Order # noqa: E501
|
from openapi_server.models.order import Order # noqa: E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
def delete_order(orderId): # noqa: E501
|
def delete_order(order_id): # noqa: E501
|
||||||
"""Delete purchase order by ID
|
"""Delete purchase order by ID
|
||||||
|
|
||||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
|
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
|
||||||
|
|
||||||
:param orderId: ID of the order that needs to be deleted
|
:param order_id: ID of the order that needs to be deleted
|
||||||
:type orderId: str
|
:type order_id: str
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
@@ -29,29 +29,29 @@ def get_inventory(): # noqa: E501
|
|||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def get_order_by_id(orderId): # noqa: E501
|
def get_order_by_id(order_id): # noqa: E501
|
||||||
"""Find purchase order by ID
|
"""Find purchase order by ID
|
||||||
|
|
||||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501
|
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501
|
||||||
|
|
||||||
:param orderId: ID of pet that needs to be fetched
|
:param order_id: ID of pet that needs to be fetched
|
||||||
:type orderId: int
|
:type order_id: int
|
||||||
|
|
||||||
:rtype: Order
|
:rtype: Order
|
||||||
"""
|
"""
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def place_order(body): # noqa: E501
|
def place_order(order): # noqa: E501
|
||||||
"""Place an order for a pet
|
"""Place an order for a pet
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param body: order placed for purchasing the pet
|
:param order: order placed for purchasing the pet
|
||||||
:type body: dict | bytes
|
:type order: dict | bytes
|
||||||
|
|
||||||
:rtype: Order
|
:rtype: Order
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = Order.from_dict(connexion.request.get_json()) # noqa: E501
|
order = Order.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
@@ -1,52 +1,52 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.user import User # noqa: E501
|
from openapi_server.models.user import User # noqa: E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
def create_user(body): # noqa: E501
|
def create_user(user): # noqa: E501
|
||||||
"""Create user
|
"""Create user
|
||||||
|
|
||||||
This can only be done by the logged in user. # noqa: E501
|
This can only be done by the logged in user. # noqa: E501
|
||||||
|
|
||||||
:param body: Created user object
|
:param user: Created user object
|
||||||
:type body: dict | bytes
|
:type user: dict | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = User.from_dict(connexion.request.get_json()) # noqa: E501
|
user = User.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def create_users_with_array_input(body): # noqa: E501
|
def create_users_with_array_input(user): # noqa: E501
|
||||||
"""Creates list of users with given input array
|
"""Creates list of users with given input array
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param body: List of user object
|
:param user: List of user object
|
||||||
:type body: list | bytes
|
:type user: list | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
|
user = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def create_users_with_list_input(body): # noqa: E501
|
def create_users_with_list_input(user): # noqa: E501
|
||||||
"""Creates list of users with given input array
|
"""Creates list of users with given input array
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param body: List of user object
|
:param user: List of user object
|
||||||
:type body: list | bytes
|
:type user: list | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
|
user = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ def get_user_by_name(username): # noqa: E501
|
|||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param username: The name that needs to be fetched. Use user1 for testing.
|
:param username: The name that needs to be fetched. Use user1 for testing.
|
||||||
:type username: str
|
:type username: str
|
||||||
|
|
||||||
:rtype: User
|
:rtype: User
|
||||||
@@ -102,18 +102,18 @@ def logout_user(): # noqa: E501
|
|||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def update_user(username, body): # noqa: E501
|
def update_user(username, user): # noqa: E501
|
||||||
"""Updated user
|
"""Updated user
|
||||||
|
|
||||||
This can only be done by the logged in user. # noqa: E501
|
This can only be done by the logged in user. # noqa: E501
|
||||||
|
|
||||||
:param username: name that need to be deleted
|
:param username: name that need to be deleted
|
||||||
:type username: str
|
:type username: str
|
||||||
:param body: Updated user object
|
:param user: Updated user object
|
||||||
:type body: dict | bytes
|
:type user: dict | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = User.from_dict(connexion.request.get_json()) # noqa: E501
|
user = User.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from connexion.apps.flask_app import FlaskJSONEncoder
|
from connexion.apps.flask_app import FlaskJSONEncoder
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
|
|
||||||
|
|
||||||
class JSONEncoder(FlaskJSONEncoder):
|
class JSONEncoder(FlaskJSONEncoder):
|
||||||
@@ -10,7 +10,7 @@ class JSONEncoder(FlaskJSONEncoder):
|
|||||||
def default(self, o):
|
def default(self, o):
|
||||||
if isinstance(o, Model):
|
if isinstance(o, Model):
|
||||||
dikt = {}
|
dikt = {}
|
||||||
for attr, _ in six.iteritems(o.swagger_types):
|
for attr, _ in six.iteritems(o.openapi_types):
|
||||||
value = getattr(o, attr)
|
value = getattr(o, attr)
|
||||||
if value is None and not self.include_nulls:
|
if value is None and not self.include_nulls:
|
||||||
continue
|
continue
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
# flake8: noqa
|
||||||
|
from __future__ import absolute_import
|
||||||
|
# import models into model package
|
||||||
|
from openapi_server.models.api_response import ApiResponse
|
||||||
|
from openapi_server.models.category import Category
|
||||||
|
from openapi_server.models.order import Order
|
||||||
|
from openapi_server.models.pet import Pet
|
||||||
|
from openapi_server.models.tag import Tag
|
||||||
|
from openapi_server.models.user import User
|
||||||
@@ -5,18 +5,18 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class ApiResponse(Model):
|
class ApiResponse(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, code: int=None, type: str=None, message: str=None): # noqa: E501
|
def __init__(self, code: int=None, type: str=None, message: str=None): # noqa: E501
|
||||||
"""ApiResponse - a model defined in Swagger
|
"""ApiResponse - a model defined in OpenAPI
|
||||||
|
|
||||||
:param code: The code of this ApiResponse. # noqa: E501
|
:param code: The code of this ApiResponse. # noqa: E501
|
||||||
:type code: int
|
:type code: int
|
||||||
@@ -25,7 +25,7 @@ class ApiResponse(Model):
|
|||||||
:param message: The message of this ApiResponse. # noqa: E501
|
:param message: The message of this ApiResponse. # noqa: E501
|
||||||
:type message: str
|
:type message: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'code': int,
|
'code': int,
|
||||||
'type': str,
|
'type': str,
|
||||||
'message': str
|
'message': str
|
||||||
@@ -3,15 +3,15 @@ import pprint
|
|||||||
import six
|
import six
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
T = typing.TypeVar('T')
|
T = typing.TypeVar('T')
|
||||||
|
|
||||||
|
|
||||||
class Model(object):
|
class Model(object):
|
||||||
# swaggerTypes: The key is attribute name and the
|
# openapiTypes: The key is attribute name and the
|
||||||
# value is attribute type.
|
# value is attribute type.
|
||||||
swagger_types = {}
|
openapi_types = {}
|
||||||
|
|
||||||
# attributeMap: The key is attribute name and the
|
# attributeMap: The key is attribute name and the
|
||||||
# value is json key in definition.
|
# value is json key in definition.
|
||||||
@@ -29,7 +29,7 @@ class Model(object):
|
|||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
for attr, _ in six.iteritems(self.swagger_types):
|
for attr, _ in six.iteritems(self.openapi_types):
|
||||||
value = getattr(self, attr)
|
value = getattr(self, attr)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
result[attr] = list(map(
|
result[attr] = list(map(
|
||||||
@@ -5,25 +5,25 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Category(Model):
|
class Category(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id: int=None, name: str=None): # noqa: E501
|
def __init__(self, id: int=None, name: str=None): # noqa: E501
|
||||||
"""Category - a model defined in Swagger
|
"""Category - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Category. # noqa: E501
|
:param id: The id of this Category. # noqa: E501
|
||||||
:type id: int
|
:type id: int
|
||||||
:param name: The name of this Category. # noqa: E501
|
:param name: The name of this Category. # noqa: E501
|
||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'name': str
|
'name': str
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,18 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Order(Model):
|
class Order(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): # noqa: E501
|
def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): # noqa: E501
|
||||||
"""Order - a model defined in Swagger
|
"""Order - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Order. # noqa: E501
|
:param id: The id of this Order. # noqa: E501
|
||||||
:type id: int
|
:type id: int
|
||||||
@@ -31,7 +31,7 @@ class Order(Model):
|
|||||||
:param complete: The complete of this Order. # noqa: E501
|
:param complete: The complete of this Order. # noqa: E501
|
||||||
:type complete: bool
|
:type complete: bool
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'pet_id': int,
|
'pet_id': int,
|
||||||
'quantity': int,
|
'quantity': int,
|
||||||
@@ -5,20 +5,20 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server.models.category import Category # noqa: F401,E501
|
from openapi_server.models.category import Category # noqa: F401,E501
|
||||||
from swagger_server.models.tag import Tag # noqa: F401,E501
|
from openapi_server.models.tag import Tag # noqa: F401,E501
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Pet(Model):
|
class Pet(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): # noqa: E501
|
def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): # noqa: E501
|
||||||
"""Pet - a model defined in Swagger
|
"""Pet - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Pet. # noqa: E501
|
:param id: The id of this Pet. # noqa: E501
|
||||||
:type id: int
|
:type id: int
|
||||||
@@ -33,7 +33,7 @@ class Pet(Model):
|
|||||||
:param status: The status of this Pet. # noqa: E501
|
:param status: The status of this Pet. # noqa: E501
|
||||||
:type status: str
|
:type status: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'category': Category,
|
'category': Category,
|
||||||
'name': str,
|
'name': str,
|
||||||
@@ -5,25 +5,25 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class Tag(Model):
|
class Tag(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id: int=None, name: str=None): # noqa: E501
|
def __init__(self, id: int=None, name: str=None): # noqa: E501
|
||||||
"""Tag - a model defined in Swagger
|
"""Tag - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this Tag. # noqa: E501
|
:param id: The id of this Tag. # noqa: E501
|
||||||
:type id: int
|
:type id: int
|
||||||
:param name: The name of this Tag. # noqa: E501
|
:param name: The name of this Tag. # noqa: E501
|
||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'name': str
|
'name': str
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,18 @@ from datetime import date, datetime # noqa: F401
|
|||||||
|
|
||||||
from typing import List, Dict # noqa: F401
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
from swagger_server.models.base_model_ import Model
|
from openapi_server.models.base_model_ import Model
|
||||||
from swagger_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class User(Model):
|
class User(Model):
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): # noqa: E501
|
def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): # noqa: E501
|
||||||
"""User - a model defined in Swagger
|
"""User - a model defined in OpenAPI
|
||||||
|
|
||||||
:param id: The id of this User. # noqa: E501
|
:param id: The id of this User. # noqa: E501
|
||||||
:type id: int
|
:type id: int
|
||||||
@@ -35,7 +35,7 @@ class User(Model):
|
|||||||
:param user_status: The user_status of this User. # noqa: E501
|
:param user_status: The user_status of this User. # noqa: E501
|
||||||
:type user_status: int
|
:type user_status: int
|
||||||
"""
|
"""
|
||||||
self.swagger_types = {
|
self.openapi_types = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'username': str,
|
'username': str,
|
||||||
'first_name': str,
|
'first_name': str,
|
||||||
@@ -0,0 +1,769 @@
|
|||||||
|
openapi: 3.0.1
|
||||||
|
info:
|
||||||
|
title: OpenAPI Petstore
|
||||||
|
description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
license:
|
||||||
|
name: Apache-2.0
|
||||||
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
version: 1.0.0
|
||||||
|
servers:
|
||||||
|
- url: http://petstore.swagger.io/v2
|
||||||
|
tags:
|
||||||
|
- name: pet
|
||||||
|
description: Everything about your Pets
|
||||||
|
- name: store
|
||||||
|
description: Access to Petstore orders
|
||||||
|
- name: user
|
||||||
|
description: Operations about user
|
||||||
|
paths:
|
||||||
|
/pet:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Update an existing pet
|
||||||
|
operationId: update_pet
|
||||||
|
requestBody:
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: Invalid ID supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: Pet not found
|
||||||
|
content: {}
|
||||||
|
405:
|
||||||
|
description: Validation exception
|
||||||
|
content: {}
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Add a new pet to the store
|
||||||
|
operationId: add_pet
|
||||||
|
requestBody:
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
405:
|
||||||
|
description: Invalid input
|
||||||
|
content: {}
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
/pet/findByStatus:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by status
|
||||||
|
description: Multiple status values can be provided with comma separated strings
|
||||||
|
operationId: find_pets_by_status
|
||||||
|
parameters:
|
||||||
|
- name: status
|
||||||
|
in: query
|
||||||
|
description: Status values that need to be considered for filter
|
||||||
|
required: true
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
default: available
|
||||||
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
400:
|
||||||
|
description: Invalid status value
|
||||||
|
content: {}
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
/pet/findByTags:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by tags
|
||||||
|
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
operationId: find_pets_by_tags
|
||||||
|
parameters:
|
||||||
|
- name: tags
|
||||||
|
in: query
|
||||||
|
description: Tags to filter by
|
||||||
|
required: true
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
400:
|
||||||
|
description: Invalid tag value
|
||||||
|
content: {}
|
||||||
|
deprecated: true
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
/pet/{petId}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Find pet by ID
|
||||||
|
description: Returns a single pet
|
||||||
|
operationId: get_pet_by_id
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to return
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
400:
|
||||||
|
description: Invalid ID supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: Pet not found
|
||||||
|
content: {}
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Updates a pet in the store with form data
|
||||||
|
operationId: update_pet_with_form
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be updated
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: Updated name of the pet
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: Updated status of the pet
|
||||||
|
responses:
|
||||||
|
405:
|
||||||
|
description: Invalid input
|
||||||
|
content: {}
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Deletes a pet
|
||||||
|
operationId: delete_pet
|
||||||
|
parameters:
|
||||||
|
- name: api_key
|
||||||
|
in: header
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: Pet id to delete
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: Invalid pet value
|
||||||
|
content: {}
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
/pet/{petId}/uploadImage:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: uploads an image
|
||||||
|
operationId: upload_file
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to update
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
additionalMetadata:
|
||||||
|
type: string
|
||||||
|
description: Additional data to pass to server
|
||||||
|
file:
|
||||||
|
type: string
|
||||||
|
description: file to upload
|
||||||
|
format: binary
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ApiResponse'
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
/store/inventory:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Returns pet inventories by status
|
||||||
|
description: Returns a map of status codes to quantities
|
||||||
|
operationId: get_inventory
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
|
/store/order:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Place an order for a pet
|
||||||
|
operationId: place_order
|
||||||
|
requestBody:
|
||||||
|
description: order placed for purchasing the pet
|
||||||
|
content:
|
||||||
|
'*/*':
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
400:
|
||||||
|
description: Invalid Order
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
|
/store/order/{orderId}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Find purchase order by ID
|
||||||
|
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
operationId: get_order_by_id
|
||||||
|
parameters:
|
||||||
|
- name: orderId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be fetched
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
maximum: 5
|
||||||
|
minimum: 1
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
400:
|
||||||
|
description: Invalid ID supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: Order not found
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Delete purchase order by ID
|
||||||
|
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
operationId: delete_order
|
||||||
|
parameters:
|
||||||
|
- name: orderId
|
||||||
|
in: path
|
||||||
|
description: ID of the order that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: Invalid ID supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: Order not found
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.store_controller
|
||||||
|
/user:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Create user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: create_user
|
||||||
|
requestBody:
|
||||||
|
description: Created user object
|
||||||
|
content:
|
||||||
|
'*/*':
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
/user/createWithArray:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
operationId: create_users_with_array_input
|
||||||
|
requestBody:
|
||||||
|
description: List of user object
|
||||||
|
content:
|
||||||
|
'*/*':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
/user/createWithList:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
operationId: create_users_with_list_input
|
||||||
|
requestBody:
|
||||||
|
description: List of user object
|
||||||
|
content:
|
||||||
|
'*/*':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
/user/login:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Logs user into the system
|
||||||
|
operationId: login_user
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: query
|
||||||
|
description: The user name for login
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: password
|
||||||
|
in: query
|
||||||
|
description: The password for login in clear text
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit:
|
||||||
|
description: calls per hour allowed by the user
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
X-Expires-After:
|
||||||
|
description: date in UTC when toekn expires
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
400:
|
||||||
|
description: Invalid username/password supplied
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
/user/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Logs out current logged in user session
|
||||||
|
operationId: logout_user
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
/user/{username}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Get user by user name
|
||||||
|
operationId: get_user_by_name
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: The name that needs to be fetched. Use user1 for testing.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
400:
|
||||||
|
description: Invalid username supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: User not found
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Updated user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: update_user
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: name that need to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
requestBody:
|
||||||
|
description: Updated user object
|
||||||
|
content:
|
||||||
|
'*/*':
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: Invalid user supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: User not found
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Delete user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: delete_user
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: The name that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: Invalid username supplied
|
||||||
|
content: {}
|
||||||
|
404:
|
||||||
|
description: User not found
|
||||||
|
content: {}
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Order:
|
||||||
|
title: Pet Order
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
petId:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
quantity:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
shipDate:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: Order Status
|
||||||
|
enum:
|
||||||
|
- placed
|
||||||
|
- approved
|
||||||
|
- delivered
|
||||||
|
complete:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
description: An order for a pets from the pet store
|
||||||
|
example:
|
||||||
|
petId: 6
|
||||||
|
quantity: 1
|
||||||
|
id: 0
|
||||||
|
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||||
|
complete: false
|
||||||
|
status: placed
|
||||||
|
xml:
|
||||||
|
name: Order
|
||||||
|
Category:
|
||||||
|
title: Pet category
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: A category for a pet
|
||||||
|
example:
|
||||||
|
name: name
|
||||||
|
id: 6
|
||||||
|
xml:
|
||||||
|
name: Category
|
||||||
|
User:
|
||||||
|
title: a User
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
firstName:
|
||||||
|
type: string
|
||||||
|
lastName:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
userStatus:
|
||||||
|
type: integer
|
||||||
|
description: User Status
|
||||||
|
format: int32
|
||||||
|
description: A User who is purchasing from the pet store
|
||||||
|
example:
|
||||||
|
firstName: firstName
|
||||||
|
lastName: lastName
|
||||||
|
password: password
|
||||||
|
userStatus: 6
|
||||||
|
phone: phone
|
||||||
|
id: 0
|
||||||
|
email: email
|
||||||
|
username: username
|
||||||
|
xml:
|
||||||
|
name: User
|
||||||
|
Tag:
|
||||||
|
title: Pet Tag
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: A tag for a pet
|
||||||
|
example:
|
||||||
|
name: name
|
||||||
|
id: 1
|
||||||
|
xml:
|
||||||
|
name: Tag
|
||||||
|
Pet:
|
||||||
|
title: a Pet
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- photoUrls
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
category:
|
||||||
|
$ref: '#/components/schemas/Category'
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: doggie
|
||||||
|
photoUrls:
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: photoUrl
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: tag
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Tag'
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: pet status in the store
|
||||||
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
description: A pet for sale in the pet store
|
||||||
|
example:
|
||||||
|
photoUrls:
|
||||||
|
- photoUrls
|
||||||
|
- photoUrls
|
||||||
|
name: doggie
|
||||||
|
id: 0
|
||||||
|
category:
|
||||||
|
name: name
|
||||||
|
id: 6
|
||||||
|
tags:
|
||||||
|
- name: name
|
||||||
|
id: 1
|
||||||
|
- name: name
|
||||||
|
id: 1
|
||||||
|
status: available
|
||||||
|
xml:
|
||||||
|
name: Pet
|
||||||
|
ApiResponse:
|
||||||
|
title: An uploaded response
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
description: Describes the result of uploading an image resource
|
||||||
|
example:
|
||||||
|
code: 0
|
||||||
|
type: type
|
||||||
|
message: message
|
||||||
|
securitySchemes:
|
||||||
|
petstore_auth:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
scopes:
|
||||||
|
write:pets: modify pets in your account
|
||||||
|
read:pets: read your pets
|
||||||
|
api_key:
|
||||||
|
type: apiKey
|
||||||
|
name: api_key
|
||||||
|
in: header
|
||||||
@@ -3,14 +3,14 @@ import logging
|
|||||||
import connexion
|
import connexion
|
||||||
from flask_testing import TestCase
|
from flask_testing import TestCase
|
||||||
|
|
||||||
from swagger_server.encoder import JSONEncoder
|
from openapi_server.encoder import JSONEncoder
|
||||||
|
|
||||||
|
|
||||||
class BaseTestCase(TestCase):
|
class BaseTestCase(TestCase):
|
||||||
|
|
||||||
def create_app(self):
|
def create_app(self):
|
||||||
logging.getLogger('connexion.operation').setLevel('ERROR')
|
logging.getLogger('connexion.operation').setLevel('ERROR')
|
||||||
app = connexion.App(__name__, specification_dir='../swagger/')
|
app = connexion.App(__name__, specification_dir='../openapi/')
|
||||||
app.app.json_encoder = JSONEncoder
|
app.app.json_encoder = JSONEncoder
|
||||||
app.add_api('swagger.yaml')
|
app.add_api('openapi.yaml')
|
||||||
return app.app
|
return app.app
|
||||||
@@ -5,9 +5,9 @@ from __future__ import absolute_import
|
|||||||
from flask import json
|
from flask import json
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
|
|
||||||
from swagger_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from swagger_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
from swagger_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestPetController(BaseTestCase):
|
class TestPetController(BaseTestCase):
|
||||||
@@ -18,11 +18,11 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
Add a new pet to the store
|
Add a new pet to the store
|
||||||
"""
|
"""
|
||||||
body = Pet()
|
pet = Pet()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet',
|
'/v2/pet',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(body),
|
data=json.dumps(pet),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -34,7 +34,7 @@ class TestPetController(BaseTestCase):
|
|||||||
"""
|
"""
|
||||||
headers = [('api_key', 'api_key_example')]
|
headers = [('api_key', 'api_key_example')]
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{petId}'.format(petId=789),
|
'/v2/pet/{petId}'.format(pet_id=56),
|
||||||
method='DELETE',
|
method='DELETE',
|
||||||
headers=headers)
|
headers=headers)
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
@@ -72,7 +72,7 @@ class TestPetController(BaseTestCase):
|
|||||||
Find pet by ID
|
Find pet by ID
|
||||||
"""
|
"""
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{petId}'.format(petId=789),
|
'/v2/pet/{petId}'.format(pet_id=56),
|
||||||
method='GET')
|
method='GET')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -82,11 +82,11 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
Update an existing pet
|
Update an existing pet
|
||||||
"""
|
"""
|
||||||
body = Pet()
|
pet = Pet()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet',
|
'/v2/pet',
|
||||||
method='PUT',
|
method='PUT',
|
||||||
data=json.dumps(body),
|
data=json.dumps(pet),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -99,7 +99,7 @@ class TestPetController(BaseTestCase):
|
|||||||
data = dict(name='name_example',
|
data = dict(name='name_example',
|
||||||
status='status_example')
|
status='status_example')
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{petId}'.format(petId=789),
|
'/v2/pet/{petId}'.format(pet_id=56),
|
||||||
method='POST',
|
method='POST',
|
||||||
data=data,
|
data=data,
|
||||||
content_type='application/x-www-form-urlencoded')
|
content_type='application/x-www-form-urlencoded')
|
||||||
@@ -111,10 +111,10 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
uploads an image
|
uploads an image
|
||||||
"""
|
"""
|
||||||
data = dict(additionalMetadata='additionalMetadata_example',
|
data = dict(additional_metadata='additional_metadata_example',
|
||||||
file=(BytesIO(b'some file data'), 'file.txt'))
|
file=(BytesIO(b'some file data'), 'file.txt'))
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{petId}/uploadImage'.format(petId=789),
|
'/v2/pet/{petId}/uploadImage'.format(pet_id=56),
|
||||||
method='POST',
|
method='POST',
|
||||||
data=data,
|
data=data,
|
||||||
content_type='multipart/form-data')
|
content_type='multipart/form-data')
|
||||||
@@ -5,8 +5,8 @@ from __future__ import absolute_import
|
|||||||
from flask import json
|
from flask import json
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
|
|
||||||
from swagger_server.models.order import Order # noqa: E501
|
from openapi_server.models.order import Order # noqa: E501
|
||||||
from swagger_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestStoreController(BaseTestCase):
|
class TestStoreController(BaseTestCase):
|
||||||
@@ -18,7 +18,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
Delete purchase order by ID
|
Delete purchase order by ID
|
||||||
"""
|
"""
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/store/order/{orderId}'.format(orderId='orderId_example'),
|
'/v2/store/order/{orderId}'.format(order_id='order_id_example'),
|
||||||
method='DELETE')
|
method='DELETE')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -40,7 +40,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
Find purchase order by ID
|
Find purchase order by ID
|
||||||
"""
|
"""
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/store/order/{orderId}'.format(orderId=5),
|
'/v2/store/order/{orderId}'.format(order_id=5),
|
||||||
method='GET')
|
method='GET')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -50,11 +50,11 @@ class TestStoreController(BaseTestCase):
|
|||||||
|
|
||||||
Place an order for a pet
|
Place an order for a pet
|
||||||
"""
|
"""
|
||||||
body = Order()
|
order = Order()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/store/order',
|
'/v2/store/order',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(body),
|
data=json.dumps(order),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -5,8 +5,8 @@ from __future__ import absolute_import
|
|||||||
from flask import json
|
from flask import json
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
|
|
||||||
from swagger_server.models.user import User # noqa: E501
|
from openapi_server.models.user import User # noqa: E501
|
||||||
from swagger_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestUserController(BaseTestCase):
|
class TestUserController(BaseTestCase):
|
||||||
@@ -17,11 +17,11 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Create user
|
Create user
|
||||||
"""
|
"""
|
||||||
body = User()
|
user = User()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user',
|
'/v2/user',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(body),
|
data=json.dumps(user),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -31,11 +31,11 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = [User()]
|
user = None
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/createWithArray',
|
'/v2/user/createWithArray',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(body),
|
data=json.dumps(user),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -45,11 +45,11 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = [User()]
|
user = None
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/createWithList',
|
'/v2/user/createWithList',
|
||||||
method='POST',
|
method='POST',
|
||||||
data=json.dumps(body),
|
data=json.dumps(user),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -106,11 +106,11 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Updated user
|
Updated user
|
||||||
"""
|
"""
|
||||||
body = User()
|
user = User()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/{username}'.format(username='username_example'),
|
'/v2/user/{username}'.format(username='username_example'),
|
||||||
method='PUT',
|
method='PUT',
|
||||||
data=json.dumps(body),
|
data=json.dumps(user),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -100,10 +100,10 @@ def deserialize_model(data, klass):
|
|||||||
"""
|
"""
|
||||||
instance = klass()
|
instance = klass()
|
||||||
|
|
||||||
if not instance.swagger_types:
|
if not instance.openapi_types:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
for attr, attr_type in six.iteritems(instance.swagger_types):
|
for attr, attr_type in six.iteritems(instance.openapi_types):
|
||||||
if data is not None \
|
if data is not None \
|
||||||
and instance.attribute_map[attr] in data \
|
and instance.attribute_map[attr] in data \
|
||||||
and isinstance(data, (list, dict)):
|
and isinstance(data, (list, dict)):
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
NAME = "swagger_server"
|
NAME = "openapi_server"
|
||||||
VERSION = "1.0.0"
|
VERSION = "1.0.0"
|
||||||
|
|
||||||
# To install the library, run the following
|
# To install the library, run the following
|
||||||
@@ -18,18 +18,18 @@ REQUIRES = ["connexion"]
|
|||||||
setup(
|
setup(
|
||||||
name=NAME,
|
name=NAME,
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
description="Swagger Petstore",
|
description="OpenAPI Petstore",
|
||||||
author_email="apiteam@swagger.io",
|
author_email="",
|
||||||
url="",
|
url="",
|
||||||
keywords=["OpenAPI", "Swagger Petstore"],
|
keywords=["OpenAPI", "OpenAPI Petstore"],
|
||||||
install_requires=REQUIRES,
|
install_requires=REQUIRES,
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
package_data={'': ['openapi/openapi.yaml']},
|
package_data={'': ['openapi/openapi.yaml']},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': ['swagger_server=swagger_server.__main__:main']},
|
'console_scripts': ['openapi_server=openapi_server.__main__:main']},
|
||||||
long_description="""\
|
long_description="""\
|
||||||
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
|
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# coding: utf-8
|
|
||||||
|
|
||||||
# flake8: noqa
|
|
||||||
from __future__ import absolute_import
|
|
||||||
# import models into model package
|
|
||||||
from swagger_server.models.api_response import ApiResponse
|
|
||||||
from swagger_server.models.category import Category
|
|
||||||
from swagger_server.models.order import Order
|
|
||||||
from swagger_server.models.pet import Pet
|
|
||||||
from swagger_server.models.tag import Tag
|
|
||||||
from swagger_server.models.user import User
|
|
||||||
Reference in New Issue
Block a user