Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the dataType if the baseType is not set #5372

Merged
merged 5 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update spec to explicitly name objects and prevent inline_object
  • Loading branch information
Justin Busschau committed Feb 21, 2020
commit b141d2535ec848b5befd9e37741409ec5f7917f1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openapi: 3.0.0
openapi: 3.0.1
servers:
- url: 'http://petstore.swagger.io/v2'
info:
Expand Down Expand Up @@ -217,17 +217,7 @@ paths:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string
$ref: '#/components/requestBodies/PetForm'
delete:
tags:
- pet
Expand Down Expand Up @@ -281,18 +271,7 @@ paths:
- 'write:pets'
- 'read:pets'
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
$ref: '#/components/requestBodies/UploadForm'
/store/inventory:
get:
tags:
Expand Down Expand Up @@ -588,7 +567,7 @@ components:
type: array
items:
$ref: '#/components/schemas/User'
description: List of user object
description: List of user objects
required: true
Pet:
content:
Expand All @@ -600,6 +579,22 @@ components:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
PetForm:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/PetForm'
example:
name: fluffy
status: available
UploadForm:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/UploadForm'
example:
additionalMetadata: additional metadata example
file: c29tZSB0ZXN0IGRhdGEK
securitySchemes:
petstore_auth:
type: oauth2
Expand Down Expand Up @@ -737,6 +732,34 @@ components:
- sold
xml:
name: Pet
PetForm:
title: A pet form
description: A form for updating a pet
type: object
required:
- name
- status
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string
UploadForm:
title: An upload form
description: A form for attaching files to a pet
type: object
required:
- file
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
ApiResponse:
title: An uploaded response
description: Describes the result of uploading an image resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

from openapi_server.models.api_response import ApiResponse # noqa: E501
from openapi_server.models.pet import Pet # noqa: E501
from openapi_server.models.pet_form import PetForm # noqa: E501
from openapi_server.models.status_enum import StatusEnum # noqa: E501
from openapi_server.models.upload_form import UploadForm # noqa: E501
from openapi_server import util


Expand Down Expand Up @@ -108,35 +110,35 @@ def update_pet_status_with_enum(pet_id, status): # noqa: E501
return 'do some magic!'


def update_pet_with_form(pet_id, name=None, status=None): # noqa: E501
def update_pet_with_form(pet_id, pet_form=None): # noqa: E501
"""Updates a pet in the store with form data

# noqa: E501

:param pet_id: ID of pet that needs to be updated
:type pet_id: int
:param name: Updated name of the pet
:type name: str
:param status: Updated status of the pet
:type status: str
:param pet_form:
:type pet_form: dict | bytes

:rtype: None
"""
if connexion.request.is_json:
pet_form = PetForm.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'


def upload_file(pet_id, additional_metadata=None, file=None): # noqa: E501
def upload_file(pet_id, upload_form=None): # noqa: E501
"""uploads an image

# noqa: E501

:param pet_id: ID of pet to update
:type pet_id: int
:param additional_metadata: Additional data to pass to server
:type additional_metadata: str
:param file: file to upload
:type file: str
:param upload_form:
:type upload_form: dict | bytes

:rtype: ApiResponse
"""
if connexion.request.is_json:
upload_form = UploadForm.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_users_with_array_input(user): # noqa: E501

# noqa: E501

:param user: List of user object
:param user: List of user objects
:type user: list | bytes

:rtype: None
Expand All @@ -40,7 +40,7 @@ def create_users_with_list_input(user): # noqa: E501

# noqa: E501

:param user: List of user object
:param user: List of user objects
:type user: list | bytes

:rtype: None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# import models into model package
from openapi_server.models.api_response import ApiResponse
from openapi_server.models.category import Category
from openapi_server.models.inline_object import InlineObject
from openapi_server.models.inline_object1 import InlineObject1
from openapi_server.models.order import Order
from openapi_server.models.pet import Pet
from openapi_server.models.pet_form import PetForm
from openapi_server.models.status_enum import StatusEnum
from openapi_server.models.tag import Tag
from openapi_server.models.upload_form import UploadForm
from openapi_server.models.user import User
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
from openapi_server import util


class InlineObject(Model):
class PetForm(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

Do not edit the class manually.
"""

def __init__(self, name=None, status=None): # noqa: E501
"""InlineObject - a model defined in OpenAPI
"""PetForm - a model defined in OpenAPI

:param name: The name of this InlineObject. # noqa: E501
:param name: The name of this PetForm. # noqa: E501
:type name: str
:param status: The status of this InlineObject. # noqa: E501
:param status: The status of this PetForm. # noqa: E501
:type status: str
"""
self.openapi_types = {
Expand All @@ -37,58 +37,62 @@ def __init__(self, name=None, status=None): # noqa: E501
self._status = status

@classmethod
def from_dict(cls, dikt) -> 'InlineObject':
def from_dict(cls, dikt) -> 'PetForm':
"""Returns the dict as a model

:param dikt: A dict.
:type: dict
:return: The inline_object of this InlineObject. # noqa: E501
:rtype: InlineObject
:return: The PetForm of this PetForm. # noqa: E501
:rtype: PetForm
"""
return util.deserialize_model(dikt, cls)

@property
def name(self):
"""Gets the name of this InlineObject.
"""Gets the name of this PetForm.

Updated name of the pet # noqa: E501

:return: The name of this InlineObject.
:return: The name of this PetForm.
:rtype: str
"""
return self._name

@name.setter
def name(self, name):
"""Sets the name of this InlineObject.
"""Sets the name of this PetForm.

Updated name of the pet # noqa: E501

:param name: The name of this InlineObject.
:param name: The name of this PetForm.
:type name: str
"""
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501

self._name = name

@property
def status(self):
"""Gets the status of this InlineObject.
"""Gets the status of this PetForm.

Updated status of the pet # noqa: E501

:return: The status of this InlineObject.
:return: The status of this PetForm.
:rtype: str
"""
return self._status

@status.setter
def status(self, status):
"""Sets the status of this InlineObject.
"""Sets the status of this PetForm.

Updated status of the pet # noqa: E501

:param status: The status of this InlineObject.
:param status: The status of this PetForm.
:type status: str
"""
if status is None:
raise ValueError("Invalid value for `status`, must not be `None`") # noqa: E501

self._status = status
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
from openapi_server import util


class InlineObject1(Model):
class UploadForm(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

Do not edit the class manually.
"""

def __init__(self, additional_metadata=None, file=None): # noqa: E501
"""InlineObject1 - a model defined in OpenAPI
"""UploadForm - a model defined in OpenAPI

:param additional_metadata: The additional_metadata of this InlineObject1. # noqa: E501
:param additional_metadata: The additional_metadata of this UploadForm. # noqa: E501
:type additional_metadata: str
:param file: The file of this InlineObject1. # noqa: E501
:param file: The file of this UploadForm. # noqa: E501
:type file: file
"""
self.openapi_types = {
Expand All @@ -37,58 +37,60 @@ def __init__(self, additional_metadata=None, file=None): # noqa: E501
self._file = file

@classmethod
def from_dict(cls, dikt) -> 'InlineObject1':
def from_dict(cls, dikt) -> 'UploadForm':
"""Returns the dict as a model

:param dikt: A dict.
:type: dict
:return: The inline_object_1 of this InlineObject1. # noqa: E501
:rtype: InlineObject1
:return: The UploadForm of this UploadForm. # noqa: E501
:rtype: UploadForm
"""
return util.deserialize_model(dikt, cls)

@property
def additional_metadata(self):
"""Gets the additional_metadata of this InlineObject1.
"""Gets the additional_metadata of this UploadForm.

Additional data to pass to server # noqa: E501

:return: The additional_metadata of this InlineObject1.
:return: The additional_metadata of this UploadForm.
:rtype: str
"""
return self._additional_metadata

@additional_metadata.setter
def additional_metadata(self, additional_metadata):
"""Sets the additional_metadata of this InlineObject1.
"""Sets the additional_metadata of this UploadForm.

Additional data to pass to server # noqa: E501

:param additional_metadata: The additional_metadata of this InlineObject1.
:param additional_metadata: The additional_metadata of this UploadForm.
:type additional_metadata: str
"""

self._additional_metadata = additional_metadata

@property
def file(self):
"""Gets the file of this InlineObject1.
"""Gets the file of this UploadForm.

file to upload # noqa: E501

:return: The file of this InlineObject1.
:return: The file of this UploadForm.
:rtype: file
"""
return self._file

@file.setter
def file(self, file):
"""Sets the file of this InlineObject1.
"""Sets the file of this UploadForm.

file to upload # noqa: E501

:param file: The file of this InlineObject1.
:param file: The file of this UploadForm.
:type file: file
"""
if file is None:
raise ValueError("Invalid value for `file`, must not be `None`") # noqa: E501

self._file = file
Loading