Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix Gradle and SBT builds for Java REST Assured generator
  • Loading branch information
joschi committed Apr 20, 2020
commit 2d658e02258b90be64739fa131f390134b47e239
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ ext {
{{#jackson}}
jackson_version = "2.10.3"
jackson_databind_version = "2.10.3"
jackson_databind_nullable_version = 0.2.1
jackson_databind_nullable_version = "0.2.1"
{{#threetenbp}}
jackson_threetenbp_version = "2.10.0"
{{/threetenbp}}
{{/jackson}}
{{#gson}}
gson_version = "2.8.6"
Expand All @@ -119,13 +122,25 @@ ext {
dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.findbugs:jsr305:3.0.2"
compile "io.rest-assured:scala-support:$rest_assured_version"
compile "io.rest-assured:rest-assured:$rest_assured_version"
{{#jackson}}
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
compile "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
{{#withXml}}
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version"
{{/withXml}}
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
{{#threetenbp}}
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_threetenbp_version"
{{/threetenbp}}
{{/jackson}}
{{#gson}}
compile "io.gsonfire:gson-fire:$gson_fire_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.21",
"io.rest-assured" % "rest-assured" % "4.3.0",
"io.rest-assured" % "scala-support" % "4.3.0",
"com.google.code.findbugs" % "jsr305" % "3.0.2",
{{#jackson}}
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.3" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.3" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.3",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.3",
{{#withXml}}
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.10.3",
{{/withXml}}
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.10.3",
{{/joda}}
{{#java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.10.3",
{{/java8}}
{{#threetenbp}}
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.10.0",
{{/threetenbp}}
{{/jackson}}
{{#gson}}
"com.google.code.gson" % "gson" % "2.8.6",
Expand All @@ -31,7 +45,7 @@ lazy val root = (project in file(".")).
"javax.validation" % "validation-api" % "2.0.1.Final" % "compile",
{{/useBeanValidation}}
{{#performBeanValidation}}
"org.hibernate" % "hibernate-validator" "6.0.19.Final" % "compile",
"org.hibernate" % "hibernate-validator" % "6.0.19.Final" % "compile",
{{/performBeanValidation}}
"junit" % "junit" % "4.13" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/rest-assured/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ext {
dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.findbugs:jsr305:3.0.2"
compile "io.rest-assured:scala-support:$rest_assured_version"
compile "io.rest-assured:rest-assured:$rest_assured_version"
compile "io.gsonfire:gson-fire:$gson_fire_version"
compile 'com.google.code.gson:gson:$gson_version'
compile "org.threeten:threetenbp:$threetenbp_version"
Expand Down
4 changes: 3 additions & 1 deletion samples/client/petstore/java/rest-assured/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.21",
"io.rest-assured" % "rest-assured" % "4.3.0",
"io.rest-assured" % "scala-support" % "4.3.0",
"com.google.code.findbugs" % "jsr305" % "3.0.2",
"com.google.code.gson" % "gson" % "2.8.6",
"io.gsonfire" % "gson-fire" % "1.8.4" % "compile",
"org.threeten" % "threetenbp" % "1.4.3" % "compile",
"com.squareup.okio" % "okio" % "1.17.5" % "compile",
"javax.validation" % "validation-api" % "2.0.1.Final" % "compile",
"org.hibernate" % "hibernate-validator" "6.0.19.Final" % "compile",
"org.hibernate" % "hibernate-validator" % "6.0.19.Final" % "compile",
"junit" % "junit" % "4.13" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)
Expand Down
9 changes: 0 additions & 9 deletions samples/client/petstore/java/rest-assured/docs/AnimalFarm.md

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public static GsonBuilder createGson() {
.registerTypeSelector(Animal.class, new TypeSelector() {
@Override
public Class getClassForElement(JsonElement readElement) {
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
classByDiscriminatorValue.put("Dog", Dog.class);
classByDiscriminatorValue.put("Cat", Cat.class);
classByDiscriminatorValue.put("BigCat", BigCat.class);
classByDiscriminatorValue.put("Animal", Animal.class);
Map classByDiscriminatorValue = new HashMap();
classByDiscriminatorValue.put("Dog".toUpperCase(Locale.ROOT), Dog.class);
classByDiscriminatorValue.put("Cat".toUpperCase(Locale.ROOT), Cat.class);
classByDiscriminatorValue.put("BigCat".toUpperCase(Locale.ROOT), BigCat.class);
classByDiscriminatorValue.put("Animal".toUpperCase(Locale.ROOT), Animal.class);
return getClassByDiscriminator(classByDiscriminatorValue,
getDiscriminatorValue(readElement, "className"));
}
Expand All @@ -77,15 +77,8 @@ private static String getDiscriminatorValue(JsonElement readElement, String disc
return element.getAsString();
}

/**
* Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
*
* @param classByDiscriminatorValue The map of discriminator values to Java classes.
* @param discriminatorValue The value of the OpenAPI discriminator in the input data.
* @return The Java class that implements the OpenAPI schema
*/
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase(Locale.ROOT));
if (null == clazz) {
throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -41,7 +41,8 @@ public class AnotherFakeApiTest {
@Before
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
() -> new RequestSpecBuilder()
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
.addFilter(new ErrorLoggingFilter())
.setBaseUri("http://petstore.swagger.io:80/v2"))).anotherFake();
}
Expand All @@ -51,9 +52,9 @@ public void createApi() {
*/
@Test
public void shouldSee200AfterCall123testSpecialTags() {
Client client = null;
Client body = null;
api.call123testSpecialTags()
.body(client).execute(r -> r.prettyPeek());
.body(body).execute(r -> r.prettyPeek());
// TODO: test validations
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -21,6 +21,7 @@
import org.threeten.bp.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
import org.openapitools.client.model.User;
import org.openapitools.client.model.XmlItem;
import org.openapitools.client.ApiClient;
import org.openapitools.client.api.FakeApi;
import io.restassured.builder.RequestSpecBuilder;
Expand Down Expand Up @@ -48,11 +49,24 @@ public class FakeApiTest {
@Before
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
() -> new RequestSpecBuilder()
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
.addFilter(new ErrorLoggingFilter())
.setBaseUri("http://petstore.swagger.io:80/v2"))).fake();
}

/**
* successful operation
*/
@Test
public void shouldSee200AfterCreateXmlItem() {
XmlItem xmlItem = null;
api.createXmlItem()
.body(xmlItem).execute(r -> r.prettyPeek());
// TODO: test validations
}


/**
* Output boolean
*/
Expand All @@ -69,7 +83,7 @@ public void shouldSee200AfterFakeOuterBooleanSerialize() {
*/
@Test
public void shouldSee200AfterFakeOuterCompositeSerialize() {
OuterComposite outerComposite = null;
OuterComposite body = null;
api.fakeOuterCompositeSerialize().execute(r -> r.prettyPeek());
// TODO: test validations
}
Expand Down Expand Up @@ -102,9 +116,9 @@ public void shouldSee200AfterFakeOuterStringSerialize() {
*/
@Test
public void shouldSee200AfterTestBodyWithFileSchema() {
FileSchemaTestClass fileSchemaTestClass = null;
FileSchemaTestClass body = null;
api.testBodyWithFileSchema()
.body(fileSchemaTestClass).execute(r -> r.prettyPeek());
.body(body).execute(r -> r.prettyPeek());
// TODO: test validations
}

Expand All @@ -115,10 +129,10 @@ public void shouldSee200AfterTestBodyWithFileSchema() {
@Test
public void shouldSee200AfterTestBodyWithQueryParams() {
String query = null;
User user = null;
User body = null;
api.testBodyWithQueryParams()
.queryQuery(query)
.body(user).execute(r -> r.prettyPeek());
.body(body).execute(r -> r.prettyPeek());
// TODO: test validations
}

Expand All @@ -128,9 +142,9 @@ public void shouldSee200AfterTestBodyWithQueryParams() {
*/
@Test
public void shouldSee200AfterTestClientModel() {
Client client = null;
Client body = null;
api.testClientModel()
.body(client).execute(r -> r.prettyPeek());
.body(body).execute(r -> r.prettyPeek());
// TODO: test validations
}

Expand Down Expand Up @@ -249,9 +263,9 @@ public void shouldSee400AfterTestGroupParameters() {
*/
@Test
public void shouldSee200AfterTestInlineAdditionalProperties() {
Map<String, String> requestBody = null;
Map<String, String> param = null;
api.testInlineAdditionalProperties()
.body(requestBody).execute(r -> r.prettyPeek());
.body(param).execute(r -> r.prettyPeek());
// TODO: test validations
}

Expand All @@ -269,4 +283,24 @@ public void shouldSee200AfterTestJsonFormData() {
// TODO: test validations
}


/**
* Success
*/
@Test
public void shouldSee200AfterTestQueryParameterCollectionFormat() {
List<String> pipe = null;
List<String> ioutil = null;
List<String> http = null;
List<String> url = null;
List<String> context = null;
api.testQueryParameterCollectionFormat()
.pipeQuery(pipe)
.ioutilQuery(ioutil)
.httpQuery(http)
.urlQuery(url)
.contextQuery(context).execute(r -> r.prettyPeek());
// TODO: test validations
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -41,7 +41,8 @@ public class FakeClassnameTags123ApiTest {
@Before
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
() -> new RequestSpecBuilder()
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
.addFilter(new ErrorLoggingFilter())
.setBaseUri("http://petstore.swagger.io:80/v2"))).fakeClassnameTags123();
}
Expand All @@ -51,9 +52,9 @@ public void createApi() {
*/
@Test
public void shouldSee200AfterTestClassname() {
Client client = null;
Client body = null;
api.testClassname()
.body(client).execute(r -> r.prettyPeek());
.body(body).execute(r -> r.prettyPeek());
// TODO: test validations
}

Expand Down
Loading