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.
10 KiB
SwaggerPetstore.FakeApi
All URIs are relative to http://petstore.swagger.io:80/v2
Method | HTTP request | Description |
---|---|---|
fakeOuterBooleanSerialize | POST /fake/outer/boolean | |
fakeOuterCompositeSerialize | POST /fake/outer/composite | |
fakeOuterNumberSerialize | POST /fake/outer/number | |
fakeOuterStringSerialize | POST /fake/outer/string | |
testClientModel | PATCH /fake | To test "client" model |
testEndpointParameters | POST /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 |
testEnumParameters | GET /fake | To test enum parameters |
fakeOuterBooleanSerialize
OuterBoolean fakeOuterBooleanSerialize(opts)
Test serialization of outer boolean types
Example
var SwaggerPetstore = require('swagger_petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var opts = {
'body': new SwaggerPetstore.OuterBoolean() // OuterBoolean | Input boolean as post body
};
apiInstance.fakeOuterBooleanSerialize(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
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
fakeOuterCompositeSerialize
OuterComposite fakeOuterCompositeSerialize(opts)
Test serialization of object with outer number type
Example
var SwaggerPetstore = require('swagger_petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var opts = {
'body': new SwaggerPetstore.OuterComposite() // OuterComposite | Input composite as post body
};
apiInstance.fakeOuterCompositeSerialize(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
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
fakeOuterNumberSerialize
OuterNumber fakeOuterNumberSerialize(opts)
Test serialization of outer number types
Example
var SwaggerPetstore = require('swagger_petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var opts = {
'body': new SwaggerPetstore.OuterNumber() // OuterNumber | Input number as post body
};
apiInstance.fakeOuterNumberSerialize(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
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
fakeOuterStringSerialize
OuterString fakeOuterStringSerialize(opts)
Test serialization of outer string types
Example
var SwaggerPetstore = require('swagger_petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var opts = {
'body': new SwaggerPetstore.OuterString() // OuterString | Input string as post body
};
apiInstance.fakeOuterStringSerialize(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
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
testClientModel
Client testClientModel(body)
To test "client" model
To test "client" model
Example
var SwaggerPetstore = require('swagger_petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var body = new SwaggerPetstore.Client(); // Client | client model
apiInstance.testClientModel(body).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
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
testEndpointParameters
testEndpointParameters(_number, _double, patternWithoutDelimiter, _byte, opts)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Example
var SwaggerPetstore = require('swagger_petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure HTTP basic authorization: http_basic_test
var http_basic_test = defaultClient.authentications['http_basic_test'];
http_basic_test.username = 'YOUR USERNAME';
http_basic_test.password = 'YOUR PASSWORD';
var apiInstance = new SwaggerPetstore.FakeApi();
var _number = 3.4; // Number | None
var _double = 1.2; // Number | None
var patternWithoutDelimiter = "patternWithoutDelimiter_example"; // String | None
var _byte = B; // Blob | None
var opts = {
'integer': 56, // Number | None
'int32': 56, // Number | None
'int64': 789, // Number | None
'_float': 3.4, // Number | None
'_string': "_string_example", // String | None
'binary': B, // Blob | None
'_date': new Date("2013-10-20"), // Date | None
'dateTime': new Date("2013-10-20T19:20:30+01:00"), // Date | None
'password': "password_example", // String | None
'callback': "callback_example" // String | None
};
apiInstance.testEndpointParameters(_number, _double, patternWithoutDelimiter, _byte, opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
_number | Number | None | |
_double | Number | None | |
patternWithoutDelimiter | String | None | |
_byte | Blob | None | |
integer | Number | None | [optional] |
int32 | Number | None | [optional] |
int64 | Number | None | [optional] |
_float | Number | None | [optional] |
_string | String | None | [optional] |
binary | Blob | None | [optional] |
_date | Date | None | [optional] |
dateTime | Date | None | [optional] |
password | String | None | [optional] |
callback | String | None | [optional] |
Return type
null (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
testEnumParameters
testEnumParameters(opts)
To test enum parameters
To test enum parameters
Example
var SwaggerPetstore = require('swagger_petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var opts = {
'enumFormStringArray': ["enumFormStringArray_example"], // [String] | Form parameter enum test (string array)
'enumFormString': "-efg", // String | Form parameter enum test (string)
'enumHeaderStringArray': ["enumHeaderStringArray_example"], // [String] | Header parameter enum test (string array)
'enumHeaderString': "-efg", // String | Header parameter enum test (string)
'enumQueryStringArray': ["enumQueryStringArray_example"], // [String] | Query parameter enum test (string array)
'enumQueryString': "-efg", // String | Query parameter enum test (string)
'enumQueryInteger': 56, // Number | Query parameter enum test (double)
'enumQueryDouble': 1.2 // Number | Query parameter enum test (double)
};
apiInstance.testEnumParameters(opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
enumFormStringArray | [String] | Form parameter enum test (string array) | [optional] |
enumFormString | String | Form parameter enum test (string) | [optional] [default to -efg] |
enumHeaderStringArray | [String] | Header parameter enum test (string array) | [optional] |
enumHeaderString | String | Header parameter enum test (string) | [optional] [default to -efg] |
enumQueryStringArray | [String] | Query parameter enum test (string array) | [optional] |
enumQueryString | String | Query parameter enum test (string) | [optional] [default to -efg] |
enumQueryInteger | Number | Query parameter enum test (double) | [optional] |
enumQueryDouble | Number | Query parameter enum test (double) | [optional] |
Return type
null (empty response body)
Authorization
No authorization required
HTTP request headers
- Content-Type: /
- Accept: /