When a spec defines a Model at the top level that is a non-aggretate type (such as string, number or boolean), it essentially represents an alias for the simple type. For example, the following spec snippet creates an alias of the boolean type that for all intents and purposes acts just like a regular boolean. definitions: JustABoolean: type: boolean This can be modeled in some languages through built-in mechanisms, such as typedefs in C++. Java, however, just not have a clean way of representing this. This change introduces an internal mechanism for representing aliases. It maintains a map in DefaultCodegen that tracks these types of definitions, and wherever it sees the "JustABoolean" type in the spec, it generates code that uses the built-in "Boolean" instead. This functionality currenlty only applies to Java, but could be extended to other languages later. The change adds a few examples of this to the fake endpoint spec for testing, which means all of the samples change as well.
13 KiB
petstore_api.FakeApi
All URIs are relative to http://petstore.swagger.io:80/v2
Method | HTTP request | Description |
---|---|---|
fake_outer_boolean_serialize | POST /fake/outer/boolean | |
fake_outer_composite_serialize | POST /fake/outer/composite | |
fake_outer_number_serialize | POST /fake/outer/number | |
fake_outer_string_serialize | POST /fake/outer/string | |
test_client_model | PATCH /fake | To test "client" model |
test_endpoint_parameters | POST /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 |
test_enum_parameters | GET /fake | To test enum parameters |
fake_outer_boolean_serialize
OuterBoolean fake_outer_boolean_serialize(body=body)
Test serialization of outer boolean types
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterBoolean() # OuterBoolean | Input boolean as post body (optional)
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | OuterBoolean | Input boolean as post body | [optional] |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: Not defined
[Back to top] [Back to API list] [Back to Model list] [Back to README]
fake_outer_composite_serialize
OuterComposite fake_outer_composite_serialize(body=body)
Test serialization of object with outer number type
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
try:
api_response = api_instance.fake_outer_composite_serialize(body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | OuterComposite | Input composite as post body | [optional] |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: Not defined
[Back to top] [Back to API list] [Back to Model list] [Back to README]
fake_outer_number_serialize
OuterNumber fake_outer_number_serialize(body=body)
Test serialization of outer number types
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterNumber() # OuterNumber | Input number as post body (optional)
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | OuterNumber | Input number as post body | [optional] |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: Not defined
[Back to top] [Back to API list] [Back to Model list] [Back to README]
fake_outer_string_serialize
OuterString fake_outer_string_serialize(body=body)
Test serialization of outer string types
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterString() # OuterString | Input string as post body (optional)
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | OuterString | Input string as post body | [optional] |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: Not defined
[Back to top] [Back to API list] [Back to Model list] [Back to README]
test_client_model
Client test_client_model(body)
To test "client" model
To test "client" model
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.Client() # Client | client model
try:
# To test \"client\" model
api_response = api_instance.test_client_model(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | Client | client model |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
test_endpoint_parameters
test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: http_basic_test
petstore_api.configuration.username = 'YOUR_USERNAME'
petstore_api.configuration.password = 'YOUR_PASSWORD'
# create an instance of the API class
api_instance = petstore_api.FakeApi()
number = 3.4 # float | None
double = 1.2 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'B' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 789 # int | None (optional)
float = 3.4 # float | None (optional)
string = 'string_example' # str | None (optional)
binary = 'B' # str | None (optional)
date = '2013-10-20' # date | None (optional)
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
number | float | None | |
double | float | None | |
pattern_without_delimiter | str | None | |
byte | str | None | |
integer | int | None | [optional] |
int32 | int | None | [optional] |
int64 | int | None | [optional] |
float | float | None | [optional] |
string | str | None | [optional] |
binary | str | None | [optional] |
date | date | None | [optional] |
date_time | datetime | None | [optional] |
password | str | None | [optional] |
param_callback | str | None | [optional] |
Return type
void (empty response body)
Authorization
HTTP request headers
- Content-Type: application/xml; charset=utf-8, application/json; charset=utf-8
- Accept: application/xml; charset=utf-8, application/json; charset=utf-8
[Back to top] [Back to API list] [Back to Model list] [Back to README]
test_enum_parameters
test_enum_parameters(enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string, enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double)
To test enum parameters
To test enum parameters
Example
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_form_string_array = ['enum_form_string_array_example'] # list[str] | Form parameter enum test (string array) (optional)
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to -efg)
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to -efg)
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to -efg)
enum_query_integer = 56 # int | Query parameter enum test (double) (optional)
enum_query_double = 1.2 # float | Query parameter enum test (double) (optional)
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string, enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double)
except ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
Parameters
Name | Type | Description | Notes |
---|---|---|---|
enum_form_string_array | list[str] | Form parameter enum test (string array) | [optional] |
enum_form_string | str | Form parameter enum test (string) | [optional] [default to -efg] |
enum_header_string_array | list[str] | Header parameter enum test (string array) | [optional] |
enum_header_string | str | Header parameter enum test (string) | [optional] [default to -efg] |
enum_query_string_array | list[str] | Query parameter enum test (string array) | [optional] |
enum_query_string | str | Query parameter enum test (string) | [optional] [default to -efg] |
enum_query_integer | int | Query parameter enum test (double) | [optional] |
enum_query_double | float | Query parameter enum test (double) | [optional] |
Return type
void (empty response body)
Authorization
No authorization required
HTTP request headers
- Content-Type: /
- Accept: /
[Back to top] [Back to API list] [Back to Model list] [Back to README]