add isPrimitiveType,baseType to parameter

This commit is contained in:
wing328 2016-03-06 15:38:50 +08:00
parent 1b652dab5e
commit 4ec8003ab5
8 changed files with 57 additions and 33 deletions

View File

@ -69,6 +69,7 @@ public abstract class AbstractGenerator {
* *
* @param config Codegen config * @param config Codegen config
* @param templateFile Template file * @param templateFile Template file
* @return String Full template file path
*/ */
public String getFullTemplateFile(CodegenConfig config, String templateFile) { public String getFullTemplateFile(CodegenConfig config, String templateFile) {
String library = config.getLibrary(); String library = config.getLibrary();

View File

@ -8,7 +8,7 @@ import java.util.List;
public class CodegenParameter { public class CodegenParameter {
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, hasMore, isContainer, isCookieParam, isBodyParam, hasMore, isContainer,
secondaryParam, isCollectionFormatMulti; secondaryParam, isCollectionFormatMulti, isPrimitiveType;
public String baseName, paramName, dataType, datatypeWithEnum, collectionFormat, description, baseType, defaultValue; public String baseName, paramName, dataType, datatypeWithEnum, collectionFormat, description, baseType, defaultValue;
public String example; // example value (x-example) public String example; // example value (x-example)
public String jsonSchema; public String jsonSchema;

View File

@ -1499,6 +1499,14 @@ public class DefaultCodegen {
} }
} }
} }
// set isPrimitiveType and baseType for allParams
/*if (languageSpecificPrimitives.contains(p.baseType)) {
p.isPrimitiveType = true;
p.baseType = getSwaggerType(p);
}*/
allParams.add(p); allParams.add(p);
if (param instanceof QueryParameter) { if (param instanceof QueryParameter) {
p.isQueryParam = new Boolean(true); p.isQueryParam = new Boolean(true);
@ -1770,7 +1778,9 @@ public class DefaultCodegen {
prop.setRequired(bp.getRequired()); prop.setRequired(bp.getRequired());
CodegenProperty cp = fromProperty("property", prop); CodegenProperty cp = fromProperty("property", prop);
if (cp != null) { if (cp != null) {
p.baseType = cp.baseType;
p.dataType = cp.datatype; p.dataType = cp.datatype;
p.isPrimitiveType = cp.isPrimitiveType;
p.isBinary = cp.datatype.toLowerCase().startsWith("byte"); p.isBinary = cp.datatype.toLowerCase().startsWith("byte");
} }
@ -1790,6 +1800,8 @@ public class DefaultCodegen {
} }
imports.add(cp.baseType); imports.add(cp.baseType);
p.dataType = cp.datatype; p.dataType = cp.datatype;
p.baseType = cp.complexType;
p.isPrimitiveType = cp.isPrimitiveType;
p.isContainer = true; p.isContainer = true;
p.isListContainer = true; p.isListContainer = true;
@ -1810,6 +1822,7 @@ public class DefaultCodegen {
name = getTypeDeclaration(name); name = getTypeDeclaration(name);
} }
p.dataType = name; p.dataType = name;
p.baseType = name;
} }
} }
p.paramName = toParamName(bp.getName()); p.paramName = toParamName(bp.getName());
@ -2456,24 +2469,34 @@ public class DefaultCodegen {
if (Boolean.TRUE.equals(property.isString)) { if (Boolean.TRUE.equals(property.isString)) {
parameter.isString = true; parameter.isString = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isBoolean)) { } else if (Boolean.TRUE.equals(property.isBoolean)) {
parameter.isBoolean = true; parameter.isBoolean = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isLong)) { } else if (Boolean.TRUE.equals(property.isLong)) {
parameter.isLong = true; parameter.isLong = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isInteger)) { } else if (Boolean.TRUE.equals(property.isInteger)) {
parameter.isInteger = true; parameter.isInteger = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isDouble)) { } else if (Boolean.TRUE.equals(property.isDouble)) {
parameter.isDouble = true; parameter.isDouble = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isFloat)) { } else if (Boolean.TRUE.equals(property.isFloat)) {
parameter.isFloat = true; parameter.isFloat = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isByteArray)) { } else if (Boolean.TRUE.equals(property.isByteArray)) {
parameter.isByteArray = true; parameter.isByteArray = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isBinary)) { } else if (Boolean.TRUE.equals(property.isBinary)) {
parameter.isByteArray = true; parameter.isByteArray = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isDate)) { } else if (Boolean.TRUE.equals(property.isDate)) {
parameter.isDate = true; parameter.isDate = true;
parameter.isPrimitiveType = true;
} else if (Boolean.TRUE.equals(property.isDateTime)) { } else if (Boolean.TRUE.equals(property.isDateTime)) {
parameter.isDateTime = true; parameter.isDateTime = true;
parameter.isPrimitiveType = true;
} else { } else {
LOGGER.debug("Property type is not primitive: " + property.datatype); LOGGER.debug("Property type is not primitive: " + property.datatype);
} }

View File

@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
Automatically generated by the Perl Swagger Codegen project: Automatically generated by the Perl Swagger Codegen project:
- Build date: 2016-03-06T14:25:02.405+08:00 - Build date: 2016-03-06T15:35:17.711+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen - Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Codegen version: - Codegen version:

View File

@ -40,7 +40,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**Pet**](docs/.md)| Pet object that needs to be added to the store | [optional] **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional]
### Return type ### Return type
@ -82,7 +82,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**Pet**](docs/.md)| Pet object that needs to be added to the store | [optional] **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional]
### Return type ### Return type
@ -124,7 +124,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**status** | [**ARRAY[string]**](docs/.md)| Status values that need to be considered for query | [optional] [default to available] **status** | [**ARRAY[string]**](string.md)| Status values that need to be considered for query | [optional] [default to available]
### Return type ### Return type
@ -166,7 +166,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**tags** | [**ARRAY[string]**](docs/.md)| Tags to filter by | [optional] **tags** | [**ARRAY[string]**](string.md)| Tags to filter by | [optional]
### Return type ### Return type
@ -208,7 +208,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet_id** | [**int**](docs/.md)| ID of pet that needs to be fetched | **pet_id** | **int**| ID of pet that needs to be fetched |
### Return type ### Return type
@ -252,9 +252,9 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet_id** | [**string**](docs/.md)| ID of pet that needs to be updated | **pet_id** | **string**| ID of pet that needs to be updated |
**name** | [**string**](docs/.md)| Updated name of the pet | [optional] **name** | **string**| Updated name of the pet | [optional]
**status** | [**string**](docs/.md)| Updated status of the pet | [optional] **status** | **string**| Updated status of the pet | [optional]
### Return type ### Return type
@ -297,8 +297,8 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet_id** | [**int**](docs/.md)| Pet id to delete | **pet_id** | **int**| Pet id to delete |
**api_key** | [**string**](docs/.md)| | [optional] **api_key** | **string**| | [optional]
### Return type ### Return type
@ -342,9 +342,9 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet_id** | [**int**](docs/.md)| ID of pet to update | **pet_id** | **int**| ID of pet to update |
**additional_metadata** | [**string**](docs/.md)| Additional data to pass to server | [optional] **additional_metadata** | **string**| Additional data to pass to server | [optional]
**file** | [**File**](docs/.md)| file to upload | [optional] **file** | [**File**](.md)| file to upload | [optional]
### Return type ### Return type
@ -386,7 +386,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet_id** | [**int**](docs/.md)| ID of pet that needs to be fetched | **pet_id** | **int**| ID of pet that needs to be fetched |
### Return type ### Return type
@ -428,7 +428,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet_id** | [**int**](docs/.md)| ID of pet that needs to be fetched | **pet_id** | **int**| ID of pet that needs to be fetched |
### Return type ### Return type
@ -470,7 +470,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**string**](docs/.md)| Pet object in the form of byte array | [optional] **body** | **string**| Pet object in the form of byte array | [optional]
### Return type ### Return type

View File

@ -35,7 +35,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**status** | [**string**](docs/.md)| Status value that needs to be considered for query | [optional] [default to placed] **status** | **string**| Status value that needs to be considered for query | [optional] [default to placed]
### Return type ### Return type
@ -157,7 +157,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**Order**](docs/.md)| order placed for purchasing the pet | [optional] **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional]
### Return type ### Return type
@ -199,7 +199,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order_id** | [**string**](docs/.md)| ID of pet that needs to be fetched | **order_id** | **string**| ID of pet that needs to be fetched |
### Return type ### Return type
@ -241,7 +241,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order_id** | [**string**](docs/.md)| ID of the order that needs to be deleted | **order_id** | **string**| ID of the order that needs to be deleted |
### Return type ### Return type

View File

@ -37,7 +37,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**User**](docs/.md)| Created user object | [optional] **body** | [**User**](User.md)| Created user object | [optional]
### Return type ### Return type
@ -79,7 +79,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**ARRAY[User]**](docs/.md)| List of user object | [optional] **body** | [**ARRAY[User]**](User.md)| List of user object | [optional]
### Return type ### Return type
@ -121,7 +121,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**body** | [**ARRAY[User]**](docs/.md)| List of user object | [optional] **body** | [**ARRAY[User]**](User.md)| List of user object | [optional]
### Return type ### Return type
@ -164,8 +164,8 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | [**string**](docs/.md)| The user name for login | [optional] **username** | **string**| The user name for login | [optional]
**password** | [**string**](docs/.md)| The password for login in clear text | [optional] **password** | **string**| The password for login in clear text | [optional]
### Return type ### Return type
@ -247,7 +247,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | [**string**](docs/.md)| The name that needs to be fetched. Use user1 for testing. | **username** | **string**| The name that needs to be fetched. Use user1 for testing. |
### Return type ### Return type
@ -290,8 +290,8 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | [**string**](docs/.md)| name that need to be deleted | **username** | **string**| name that need to be deleted |
**body** | [**User**](docs/.md)| Updated user object | [optional] **body** | [**User**](User.md)| Updated user object | [optional]
### Return type ### Return type
@ -333,7 +333,7 @@ if ($@) {
### Parameters ### Parameters
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | [**string**](docs/.md)| The name that needs to be deleted | **username** | **string**| The name that needs to be deleted |
### Return type ### Return type

View File

@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
default => sub { { default => sub { {
app_name => 'Swagger Petstore', app_name => 'Swagger Petstore',
app_version => '1.0.0', app_version => '1.0.0',
generated_date => '2016-03-06T14:25:02.405+08:00', generated_date => '2016-03-06T15:35:17.711+08:00',
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
} }, } },
documentation => 'Information about the application version and the codegen codebase version' documentation => 'Information about the application version and the codegen codebase version'
@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
=over 4 =over 4
=item Build date: 2016-03-06T14:25:02.405+08:00 =item Build date: 2016-03-06T15:35:17.711+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen =item Build package: class io.swagger.codegen.languages.PerlClientCodegen