Skip to content

Commit

Permalink
fix java binary mapping (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored and jmini committed Apr 20, 2018
1 parent 28a1255 commit 03490e9
Show file tree
Hide file tree
Showing 27 changed files with 680 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public DefaultCodegen() {
typeMapping.put("object", "Object");
typeMapping.put("integer", "Integer");
typeMapping.put("ByteArray", "byte[]");
typeMapping.put("binary", "byte[]");
typeMapping.put("binary", "File");
typeMapping.put("file", "File");
typeMapping.put("UUID", "UUID");
//typeMapping.put("BigDecimal", "BigDecimal"); //TODO need the mapping?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public AbstractJavaCodegen() {
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");

hideGenerationTimestamp = false;
hideGenerationTimestamp = false;

setReservedWordsLowerCase(
Arrays.asList(
// used as internal variables, can collide with parameter names
Expand Down Expand Up @@ -801,19 +801,19 @@ public String toExampleValue(Schema p) {

@Override
public String getSchemaType(Schema p) {
String swaggerType = super.getSchemaType(p);
String openAPIType = super.getSchemaType(p);

swaggerType = getAlias(swaggerType);
openAPIType = getAlias(openAPIType);

// don't apply renaming on types from the typeMapping
if (typeMapping.containsKey(swaggerType)) {
return typeMapping.get(swaggerType);
if (typeMapping.containsKey(openAPIType)) {
return typeMapping.get(openAPIType);
}

if (null == swaggerType) {
if (null == openAPIType) {
LOGGER.error("No Type defined for Schema " + p);
}
return toModelName(swaggerType);
return toModelName(openAPIType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
return false;
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}{{#isByteArray}}Arrays{{/isByteArray}}{{#isBinary}}Arrays{{/isBinary}}{{^isByteArray}}{{^isBinary}}Objects{{/isBinary}}{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
return {{#vars}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
}

@Override
public int hashCode() {
return Objects.hash({{#vars}}{{^isByteArray}}{{^isBinary}}{{name}}{{/isBinary}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{#isBinary}}Arrays.hashCode({{name}}){{/isBinary}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
return Objects.hash({{#vars}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
}

{{/supportJava6}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Method | HTTP request | Description

<a name="testSpecialTags"></a>
# **testSpecialTags**
> Client testSpecialTags(body)
> Client testSpecialTags(client)
To test special tags

Expand All @@ -23,9 +23,9 @@ To test special tags


AnotherFakeApi apiInstance = new AnotherFakeApi();
Client body = new Client(); // Client | client model
Client client = new Client(); // Client | client model
try {
Client result = apiInstance.testSpecialTags(body);
Client result = apiInstance.testSpecialTags(client);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AnotherFakeApi#testSpecialTags");
Expand All @@ -37,7 +37,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |
**client** | [**Client**](Client.md)| client model |

### Return type

Expand Down
10 changes: 10 additions & 0 deletions samples/client/petstore/java/jersey2-java8/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional]
**enumStringRequired** | [**EnumStringRequiredEnum**](#EnumStringRequiredEnum) | |
**enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional]
**enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional]
**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional]
Expand All @@ -19,6 +20,15 @@ LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumStringRequiredEnum"></a>
## Enum: EnumStringRequiredEnum
Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
## Enum: EnumIntegerEnum
Name | Value
Expand Down
Loading

0 comments on commit 03490e9

Please sign in to comment.