Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ced5763
Add source folder variable to fastapi fix 12118
rk0n Apr 12, 2022
ce2dbdc
Add generated sample files for python-fastapi fix 12118
rk0n Apr 12, 2022
83af2ca
[python-experimental] fixes json + charset use case (#12114)
spacether Apr 12, 2022
216ee06
Add example allOf with single ref (#10948)
kuhnroyal Apr 12, 2022
8ae7b89
Add a sample of an enum model array in query params (#12107)
kuhnroyal Apr 12, 2022
82f35b3
[typescript-fetch] drop support typescript under v4.0 (#12102)
mkusaka Apr 12, 2022
f31aab2
update samples
wing328 Apr 12, 2022
8b0e3f0
[dart] Remove old dio generator (to be replaced with dart-dio-next) (…
kuhnroyal Apr 12, 2022
5adc7ee
fix: respect configured generator URL in swagger config (#12064)
fgreinacher Apr 12, 2022
4dacc0e
[typescript*] drop support typescript below 4.0 (#12123)
mkusaka Apr 12, 2022
6d089d1
Upgrade haskell-servant to latest LTS (#12092)
7omb Apr 12, 2022
82d41d5
[C++][Qt] update petstore to 3.0 spec (#12124)
wing328 Apr 13, 2022
69440ec
update readme with onesignal (#12126)
wing328 Apr 13, 2022
d071fc5
[typescript-fetch] Removed functions that are unused when withoutRunt…
mkusaka Apr 13, 2022
d833794
[kotlin][client] fix encoding of individual parts of a multipart requ…
koscejev Apr 13, 2022
e70f243
[python-experimental] Allow response media types to omit schema (#12135)
spacether Apr 13, 2022
aaf9f83
improve errorObjectType to avoid regression (#12131)
wing328 Apr 14, 2022
fecdf0d
[php-slim4] Add monolog package as default logger (#12137)
ybelenko Apr 16, 2022
244f109
Bump async from 2.6.3 to 2.6.4 in /website (#12148)
dependabot[bot] Apr 16, 2022
6e7f2a8
do not put the invalid value of the enum to a JSON structure (#12133)
ityuhui Apr 16, 2022
e243117
[Java] Ignore return value for Java file assert classes (#12145)
borsch Apr 16, 2022
a5132bd
Add @mkusaka to TS technical committee (#12150)
wing328 Apr 16, 2022
77fc9ff
Fix documentation for users of AbstractJavaJAXRSServerCodegen (#12142)
typetetris Apr 16, 2022
c95ee48
[Dart][client] Adjust toJson method to use '_json' instead of 'json' …
0xNF Apr 16, 2022
ac8906a
[dart] Support/Fix sourceFolder parameter and docs (#12113)
kuhnroyal Apr 16, 2022
ce326da
[Ruby] Add support for faraday 2.x (#12112)
ykitamura-mdsol Apr 16, 2022
aaa1c26
[Java/Spring] all-of and one-of Improvements and Fixes (was #12075) (…
cachescrubber Apr 16, 2022
ef17120
[REQ][Ruby] Ruby Allow Follow Redirect (#12047)
moorec22 Apr 16, 2022
feefaf7
set follow_location default to true
wing328 Apr 16, 2022
64ccf06
Adds UUID to python-experimental (#12153)
spacether Apr 16, 2022
899c8e1
update url to travis ci
wing328 Apr 17, 2022
59dc481
Adds not to CodegenComposedSchemas and uses it in python-exp (#12146)
spacether Apr 17, 2022
1f48d76
[python-experimental] fixes bug where some singleton representations …
spacether Apr 17, 2022
cfd51ef
[swift5] Abstract away URLSession (#11651) (#12110)
leszek-s Apr 19, 2022
2e2e557
[Java][OkHTTP] fix empty request body handling (#12172)
borsch Apr 19, 2022
4b2685c
Better inline model resolver to handle inline schema in array item (#…
wing328 Apr 20, 2022
28128e6
[Inline model resolver] minor enhancements/refactoring (#12175)
wing328 Apr 20, 2022
33085f1
[python-experimental] Fixes enum is comparison (#12176)
spacether Apr 20, 2022
dd9f7b5
[php] make ObjectSerializer::toString actually return a string (#12158)
fengelniederhammer Apr 20, 2022
859bfa0
update php samples
wing328 Apr 20, 2022
0cb59fc
Allow selection of MP REST API version for MicroProfile REST client g…
aserkes Apr 20, 2022
7bacfc0
[Java][microprofile] update API test template to work with v3.0 (#12177)
wing328 Apr 20, 2022
52b8368
Return type for Azure funcs (#12115)
Abrhm7786 Apr 20, 2022
0a4b3c9
update doc
wing328 Apr 20, 2022
eb36fc7
Improvements to csharp-netcore-function generator (#12183)
wing328 Apr 20, 2022
178ca12
[java-micronaut] Support Optional for non-required properties (#12144)
auke- Apr 21, 2022
537b1a6
update java samples
wing328 Apr 21, 2022
f41e756
[typescript-fetch] allow initOverrides with async function (#12098)
mkusaka Apr 23, 2022
cce98b8
[Wsdl] Adding cli-option for generating different versions of WSDL-fi…
adessoDpd Apr 24, 2022
dcf8431
[python-flask] Fix return type too strict (#12190)
OJFord Apr 24, 2022
04ece4d
update samples, docs
wing328 Apr 24, 2022
67dc856
Fixing bug in Kotlin Client with BigDecimal default value (#12213)
sjoblomj Apr 24, 2022
ec2778f
Fix duplication of "Api" when structPrefix is set (#12128)
impl Apr 24, 2022
980975a
add samples/client/petstore/kotlin-bigdecimal-default to kotlin ci tests
wing328 Apr 24, 2022
54b6eb5
remove spring-mvc samples (#12222)
wing328 Apr 24, 2022
bfc9f2e
[Micronaut] Add option to describe response wrappers (#12186)
andriy-dmytruk Apr 24, 2022
10d0dbf
Emit default values for aspnetcore 3 value types (#11280)
hauntingEcho Apr 24, 2022
a1e51b3
update samples
wing328 Apr 24, 2022
38b0d9d
Merge branch 'master' into add-source-folder-variable-to-fastapi-fix-…
rk0n Apr 24, 2022
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
[python-experimental] Allow response media types to omit schema (#12135)
* Adds issue spec file and attemts to generate code from it

* Adds missing schema definitions

* Skips fromProperty invocation if the passed in schema is none in getContent

* Makes MediaType.schema optional

* Adds checking that the content type is in self.content

* Sets ApiResponse body type as Unset if there is no schema for it

* Handles schema = None case

* Adds endpoint without response schema

* Reverts version files

* Adds test_response_without_schema
  • Loading branch information
spacether authored and rk0n committed Apr 24, 2022
commit e70f243ea6136ab8986bd26a15836537716d4077
Original file line number Diff line number Diff line change
Expand Up @@ -6753,7 +6753,10 @@ protected LinkedHashMap<String, CodegenMediaType> getContent(Content content, Se
}
}
String contentType = contentEntry.getKey();
CodegenProperty schemaProp = fromProperty(toMediaTypeSchemaName(contentType, mediaTypeSchemaSuffix), mt.getSchema());
CodegenProperty schemaProp = null;
if (mt.getSchema() != null) {
schemaProp = fromProperty(toMediaTypeSchemaName(contentType, mediaTypeSchemaSuffix), mt.getSchema());
}
CodegenMediaType codegenMt = new CodegenMediaType(schemaProp, ceMap);
cmtContent.put(contentType, codegenMt);
if (schemaProp != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ class Encoding:
self.allow_reserved = allow_reserved


@dataclass
class MediaType:
"""
Used to store request and response body schema information
Expand All @@ -682,14 +683,8 @@ class MediaType:
The encoding object SHALL only apply to requestBody objects when the media type is
multipart or application/x-www-form-urlencoded.
"""

def __init__(
self,
schema: typing.Type[Schema],
encoding: typing.Optional[typing.Dict[str, Encoding]] = None,
):
self.schema = schema
self.encoding = encoding
schema: typing.Optional[typing.Type[Schema]] = None
encoding: typing.Optional[typing.Dict[str, Encoding]] = None


@dataclass
Expand Down Expand Up @@ -808,7 +803,27 @@ class OpenApiResponse(JSONDetector):
content_type = response.getheader('content-type')
deserialized_body = unset
streamed = response.supports_chunked_reads()

deserialized_headers = unset
if self.headers is not None:
# TODO add header deserialiation here
pass

if self.content is not None:
if content_type not in self.content:
raise ApiValueError(
f'Invalid content_type={content_type} returned for response with '
'status_code={str(response.status)}'
)
body_schema = self.content[content_type].schema
if body_schema is None:
# some specs do not define response content media type schemas
return self.response_cls(
response=response,
headers=deserialized_headers,
body=unset
)

if self.content_type_is_json(content_type):
body_data = self.__deserialize_json(response)
elif content_type == 'application/octet-stream':
Expand All @@ -818,16 +833,11 @@ class OpenApiResponse(JSONDetector):
content_type = 'multipart/form-data'
else:
raise NotImplementedError('Deserialization of {} has not yet been implemented'.format(content_type))
body_schema = self.content[content_type].schema
deserialized_body = body_schema._from_openapi_data(
body_data, _configuration=configuration)
elif streamed:
response.release_conn()

deserialized_headers = unset
if self.headers is not None:
deserialized_headers = unset

return self.response_cls(
response=response,
headers=deserialized_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ default | ApiResponseForDefault | {{message}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
response | urllib3.HTTPResponse | Raw response |
body | {{#unless content}}Unset{{else}}typing.Union[{{#each content}}{{this.schema.baseName}}, {{/each}}]{{/unless}} | {{#unless content}}body was not defined{{/unless}} |
body | {{#unless content}}Unset{{else}}typing.Union[{{#each content}}{{#if this.schema}}{{this.schema.baseName}}{{else}}Unset{{/if}}, {{/each}}]{{/unless}} | {{#unless content}}body was not defined{{/unless}} |
headers | {{#unless responseHeaders}}Unset{{else}}ResponseHeadersFor{{code}}{{/unless}} | {{#unless responseHeaders}}headers were not defined{{/unless}} |
{{#each content}}
{{#with this.schema}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ class RequestCookieParams(RequestRequiredCookieParams, RequestOptionalCookiePara
request_body_{{paramName}} = api_client.RequestBody(
content={
{{#each content}}
'{{{@key}}}': api_client.MediaType(
schema={{this.schema.baseName}}),
'{{{@key}}}': api_client.MediaType({{#if this.schema}}
schema={{this.schema.baseName}}{{/if}}),
{{/each}}
},
{{#if required}}
Expand Down Expand Up @@ -285,7 +285,11 @@ class ApiResponseFor{{code}}(api_client.ApiResponse):
{{#and responseHeaders content}}
body: typing.Union[
{{#each content}}
{{#if this.schema}}
{{this.schema.baseName}},
{{else}}
Unset,
{{/if}}
{{/each}}
]
headers: ResponseHeadersFor{{code}}
Expand All @@ -297,7 +301,11 @@ class ApiResponseFor{{code}}(api_client.ApiResponse):
{{else}}
body: typing.Union[
{{#each content}}
{{#if this.schema}}
{{this.schema.baseName}},
{{else}}
Unset,
{{/if}}
{{/each}}
]
headers: Unset = unset
Expand All @@ -323,8 +331,8 @@ _response_for_{{code}} = api_client.OpenApiResponse(
{{#if @first}}
content={
{{/if}}
'{{{@key}}}': api_client.MediaType(
schema={{this.schema.baseName}}),
'{{{@key}}}': api_client.MediaType({{#if this.schema}}
schema={{this.schema.baseName}}{{/if}}),
{{#if @last}}
},
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,18 @@ paths:
content:
application/json; charset=utf-8:
schema: {}
"/fake/responseWithoutSchema":
get:
tags:
- fake
summary: receives a response without schema
operationId: responseWithoutSchema
responses:
'200':
description: contents without schema definition
content:
application/json: {}
application/xml: {}
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Class | Method | HTTP request | Description
*FakeApi* | [**parameter_collisions**](docs/FakeApi.md#parameter_collisions) | **POST** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
*FakeApi* | [**query_parameter_collection_format**](docs/FakeApi.md#query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
*FakeApi* | [**ref_object_in_query**](docs/FakeApi.md#ref_object_in_query) | **GET** /fake/refObjInQuery | user list
*FakeApi* | [**response_without_schema**](docs/FakeApi.md#response_without_schema) | **GET** /fake/responseWithoutSchema | receives a response without schema
*FakeApi* | [**string**](docs/FakeApi.md#string) | **POST** /fake/refs/string |
*FakeApi* | [**string_enum**](docs/FakeApi.md#string_enum) | **POST** /fake/refs/enum |
*FakeApi* | [**upload_download_file**](docs/FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Method | HTTP request | Description
[**parameter_collisions**](FakeApi.md#parameter_collisions) | **POST** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
[**query_parameter_collection_format**](FakeApi.md#query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
[**ref_object_in_query**](FakeApi.md#ref_object_in_query) | **GET** /fake/refObjInQuery | user list
[**response_without_schema**](FakeApi.md#response_without_schema) | **GET** /fake/responseWithoutSchema | receives a response without schema
[**string**](FakeApi.md#string) | **POST** /fake/refs/string |
[**string_enum**](FakeApi.md#string_enum) | **POST** /fake/refs/enum |
[**upload_download_file**](FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
Expand Down Expand Up @@ -2547,6 +2548,61 @@ body | Unset | body was not defined |
headers | Unset | headers were not defined |


void (empty response body)

### Authorization

No authorization required

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **response_without_schema**
> response_without_schema()

receives a response without schema

### Example

```python
import petstore_api
from petstore_api.api import fake_api
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)

# example, this endpoint has no required or optional parameters
try:
# receives a response without schema
api_response = api_instance.response_without_schema()
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->response_without_schema: %s\n" % e)
```
### Parameters
This endpoint does not need any parameter.

### Return Types, Responses

Code | Class | Description
------------- | ------------- | -------------
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
200 | ApiResponseFor200 | contents without schema definition

#### ApiResponseFor200
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
response | urllib3.HTTPResponse | Raw response |
body | typing.Union[Unset, Unset, ] | |
headers | Unset | headers were not defined |


void (empty response body)

### Authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from petstore_api.api.fake_api_endpoints.parameter_collisions import ParameterCollisions
from petstore_api.api.fake_api_endpoints.query_parameter_collection_format import QueryParameterCollectionFormat
from petstore_api.api.fake_api_endpoints.ref_object_in_query import RefObjectInQuery
from petstore_api.api.fake_api_endpoints.response_without_schema import ResponseWithoutSchema
from petstore_api.api.fake_api_endpoints.string import String
from petstore_api.api.fake_api_endpoints.string_enum import StringEnum
from petstore_api.api.fake_api_endpoints.upload_download_file import UploadDownloadFile
Expand Down Expand Up @@ -66,6 +67,7 @@ class FakeApi(
ParameterCollisions,
QueryParameterCollectionFormat,
RefObjectInQuery,
ResponseWithoutSchema,
String,
StringEnum,
UploadDownloadFile,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# coding: utf-8

"""


Generated by: https://openapi-generator.tech
"""

from dataclasses import dataclass
import re # noqa: F401
import sys # noqa: F401
import typing
import urllib3
from urllib3._collections import HTTPHeaderDict

from petstore_api import api_client, exceptions
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401

from petstore_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)

_path = '/fake/responseWithoutSchema'
_method = 'GET'


@dataclass
class ApiResponseFor200(api_client.ApiResponse):
response: urllib3.HTTPResponse
body: typing.Union[
Unset,
Unset,
]
headers: Unset = unset


_response_for_200 = api_client.OpenApiResponse(
response_cls=ApiResponseFor200,
content={
'application/json': api_client.MediaType(),
'application/xml': api_client.MediaType(),
},
)
_status_code_to_response = {
'200': _response_for_200,
}
_all_accept_content_types = (
'application/json',
'application/xml',
)


class ResponseWithoutSchema(api_client.Api):

def response_without_schema(
self: api_client.Api,
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
"""
receives a response without schema
:param skip_deserialization: If true then api_response.response will be set but
api_response.body and api_response.headers will not be deserialized into schema
class instances
"""

_headers = HTTPHeaderDict()
# TODO add cookie handling
if accept_content_types:
for accept_content_type in accept_content_types:
_headers.add('Accept', accept_content_type)

response = self.api_client.call_api(
resource_path=_path,
method=_method,
headers=_headers,
stream=stream,
timeout=timeout,
)

if skip_deserialization:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
else:
response_for_status = _status_code_to_response.get(str(response.status))
if response_for_status:
api_response = response_for_status.deserialize(response, self.api_client.configuration)
else:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)

if not 200 <= response.status <= 299:
raise exceptions.ApiException(api_response=api_response)

return api_response
Loading