Skip to content

Commit

Permalink
Fix isPrimitiveType flag for array of form parameters (#38)
Browse files Browse the repository at this point in the history
* fix isprimitivetype for array of form parameters

* setup snapshot deployment
  • Loading branch information
wing328 authored May 14, 2018
1 parent 10ac402 commit 67ebe17
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ after_success:
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
# push a snapshot version to maven repo
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_BRANCH" = "master" ]; then
mvn clean deploy --settings .travis/settings.xml;
mvn clean deploy --settings CI/settings.xml;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
fi;

Expand Down
18 changes: 0 additions & 18 deletions .travis/settings.xml

This file was deleted.

18 changes: 18 additions & 0 deletions CI/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<settings>
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -4083,6 +4083,7 @@ public List<CodegenParameter> fromRequestBodyToFormParameters(RequestBody body,
CodegenProperty codegenProperty = fromProperty("inner", inner);
codegenParameter.items = codegenProperty;
codegenParameter.baseType = codegenProperty.datatype;
codegenParameter.isPrimitiveType = false;
codegenParameter.isContainer = true;
codegenParameter.isListContainer = true;
codegenParameter.description = s.getDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

package org.openapitools.codegen.go;

import org.testng.Assert;
import org.testng.annotations.Test;

import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.languages.GoClientCodegen;
import org.openapitools.codegen.languages.RubyClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;

public class GoClientCodegenTest {

Expand Down Expand Up @@ -54,4 +60,16 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception {
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
}

@Test(description = "test example value for body parameter")
public void bodyParameterTest() {
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml", null, new ParseOptions()).getOpenAPI();
final GoClientCodegen codegen = new GoClientCodegen();
final String path = "/fake";
final Operation p = openAPI.getPaths().get(path).getGet();
final CodegenOperation op = codegen.fromOperation(path, "post", p, openAPI.getComponents().getSchemas());
Assert.assertEquals(op.formParams.size(), 2);
CodegenParameter bp = op.formParams.get(0);
Assert.assertFalse(bp.isPrimitiveType);
}

}
Loading

0 comments on commit 67ebe17

Please # to comment.