diff --git a/README.md b/README.md index d2d3f40792dc..41eb5b2cd850 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ ## Overview This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported: -- **API clients**: **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node) +- **API clients**: **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node) - **Server stubs**: **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin**, **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra) - **API documentation generators**: **HTML**, **Confluence Wiki** - **Configuration files**: [**Apache2**](https://httpd.apache.org/) @@ -530,6 +530,7 @@ CONFIG OPTIONS retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0) retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2) google-api-client - HTTP client: google-api-client 1.23.0. JSON processing: Jackson 2.8.9 + rest-assured - HTTP client: rest-assured : 3.0.6. JSON processing: Gson 2.6.1. Only for Java8 ``` Your config file for Java can look like diff --git a/bin/java-petstore-all.sh b/bin/java-petstore-all.sh index 4abe8e6c3036..0566f775d407 100755 --- a/bin/java-petstore-all.sh +++ b/bin/java-petstore-all.sh @@ -17,3 +17,4 @@ ./bin/java-petstore-resttemplate-withxml.sh ./bin/java-petstore-resteasy.sh ./bin/java-petstore-google-api-client.sh +./bin/java-petstore-rest-assured.sh diff --git a/bin/java-petstore-rest-assured.json b/bin/java-petstore-rest-assured.json new file mode 100644 index 000000000000..0e56d218fa20 --- /dev/null +++ b/bin/java-petstore-rest-assured.json @@ -0,0 +1,4 @@ +{ + "library": "rest-assured", + "artifactId": "swagger-petstore-rest-assured" +} diff --git a/bin/java-petstore-rest-assured.sh b/bin/java-petstore-rest-assured.sh new file mode 100755 index 000000000000..a0917da67b6e --- /dev/null +++ b/bin/java-petstore-rest-assured.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-rest-assured.json -o samples/client/petstore/java/rest-assured -DhideGenerationTimestamp=true" + +echo "Removing files and folders under samples/client/petstore/java/rest-assured/src/main" +rm -rf samples/client/petstore/java/rest-assured/src/main +find samples/client/petstore/java/rest-assured -maxdepth 1 -type f ! -name "README.md" -exec rm {} + +java $JAVA_OPTS -jar $executable $ags + diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 9ef0e34aa996..dc010c36fe11 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -39,6 +39,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen public static final String RETROFIT_1 = "retrofit"; public static final String RETROFIT_2 = "retrofit2"; + public static final String REST_ASSURED = "rest-assured"; protected String gradleWrapperPackage = "gradle.wrapper"; protected boolean useRxJava = false; @@ -83,6 +84,7 @@ public JavaClientCodegen() { supportedLibraries.put("resteasy", "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9"); supportedLibraries.put("vertx", "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9"); supportedLibraries.put("google-api-client", "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9"); + supportedLibraries.put("rest-assured", "HTTP client: rest-assured : 3.0.6. JSON processing: Gson 2.6.1. Only for Java8"); CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); libraryOption.setEnum(supportedLibraries); @@ -169,12 +171,12 @@ public void processOpts() { writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); - if(!"resttemplate".equals(getLibrary())) { + if(!("resttemplate".equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) { supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); } // google-api-client doesn't use the Swagger auth, because it uses Google Credential directly (HttpRequestInitializer) - if (!"google-api-client".equals(getLibrary())) { + if (!("google-api-client".equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) { supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java")); supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java")); supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java")); @@ -200,7 +202,7 @@ public void processOpts() { apiDocTemplateFiles.remove("api_doc.mustache"); } - if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary() || "google-api-client".equals(getLibrary()))) { + if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary() || "google-api-client".equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) { supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java")); supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java")); supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java")); @@ -246,6 +248,13 @@ public void processOpts() { supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); } else if ("google-api-client".equals(getLibrary())) { additionalProperties.put("jackson", "true"); + + } else if (REST_ASSURED.equals(getLibrary())) { + additionalProperties.put("gson", "true"); + apiTemplateFiles.put("api.mustache", ".java"); + supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.java")); + supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); + supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java")); } else { LOGGER.error("Unknown library option (-l/--library): " + getLibrary()); } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/JSON.mustache b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache similarity index 93% rename from modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/JSON.mustache rename to modules/swagger-codegen/src/main/resources/Java/JSON.mustache index 63814a361fce..34ae1795cf86 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/JSON.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache @@ -26,7 +26,6 @@ import org.threeten.bp.format.DateTimeFormatter; {{/threetenbp}} import {{modelPackage}}.*; -import okio.ByteString; import java.io.IOException; import java.io.StringReader; @@ -56,7 +55,6 @@ public class JSON { private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); {{/jsr310}} - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); public static GsonBuilder createGson() { GsonFireBuilder fireBuilder = new GsonFireBuilder() @@ -107,7 +105,6 @@ public class JSON { .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) {{/jsr310}} - .registerTypeAdapter(byte[].class, byteArrayAdapter) .create(); } @@ -174,34 +171,6 @@ public class JSON { } } - /** - * Gson TypeAdapter for Byte Array type - */ - public class ByteArrayAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } - } - - @Override - public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } - } - {{#joda}} /** * Gson TypeAdapter for Joda DateTime type diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache new file mode 100644 index 000000000000..2b2698548722 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache @@ -0,0 +1,59 @@ +{{>licenseInfo}} + +package {{invokerPackage}}; + +import {{apiPackage}}.*; + +{{#imports}}import {{import}}; +{{/imports}} + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +{{/fullJavaUtil}} + +public class ApiClient { + + private final Config config; + + private ApiClient(Config config) { + this.config = config; + } + + public static ApiClient api(Config config) { + return new ApiClient(config); + } + + {{#apiInfo}} + {{#apis}} + public {{classname}} {{classVarName}}() { + return {{classname}}.{{classVarName}}(config.baseReqSpec.get()); + } + {{/apis}} + {{/apiInfo}} + + public static class Config { + private Supplier baseReqSpec; + + /** + * Use common specification for all operations + */ + public Config reqSpecSupplier(Supplier supplier) { + this.baseReqSpec = supplier; + return this; + } + + public static Config apiConfig() { + return new Config(); + } + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/GsonObjectMapper.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/GsonObjectMapper.mustache new file mode 100644 index 000000000000..320d8141f950 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/GsonObjectMapper.mustache @@ -0,0 +1,30 @@ +{{>licenseInfo}} + +package {{invokerPackage}}; + +import io.restassured.mapper.ObjectMapper; +import io.restassured.mapper.ObjectMapperDeserializationContext; +import io.restassured.mapper.ObjectMapperSerializationContext; + +public class GsonObjectMapper implements ObjectMapper { + + private JSON json; + + private GsonObjectMapper() { + this.json = new JSON(); + } + + public static GsonObjectMapper gson() { + return new GsonObjectMapper(); + } + + @Override + public Object deserialize(ObjectMapperDeserializationContext context) { + return json.deserialize(context.getDataToDeserialize().asString(), context.getType()); + } + + @Override + public Object serialize(ObjectMapperSerializationContext context) { + return json.serialize(context.getObjectToSerialize()); + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/README.mustache new file mode 100644 index 000000000000..56560172ee3b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/README.mustache @@ -0,0 +1,43 @@ +# {{artifactId}} + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation & Usage + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: + +```xml + + {{groupId}} + {{artifactId}} + {{artifactVersion}} + compile + + +``` + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/ResponseSpecBuilders.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/ResponseSpecBuilders.mustache new file mode 100644 index 000000000000..af7e7ac960f8 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/ResponseSpecBuilders.mustache @@ -0,0 +1,31 @@ +{{>licenseInfo}} + +package {{invokerPackage}}; + +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; +import io.restassured.specification.ResponseSpecification; + +import java.util.function.Function; + +public class ResponseSpecBuilders { + + private ResponseSpecBuilders() { + } + + public static Function validatedWith(ResponseSpecification respSpec) { + return response -> response.then().spec(respSpec).extract().response(); + } + + public static Function validatedWith(ResponseSpecBuilder respSpec) { + return validatedWith(respSpec.build()); + } + + /** + * @param code expected status code + * @return ResponseSpecBuilder + */ + public static ResponseSpecBuilder shouldBeCode(int code) { + return new ResponseSpecBuilder().expectStatusCode(code); + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api.mustache new file mode 100644 index 000000000000..940a25c269b7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api.mustache @@ -0,0 +1,235 @@ +{{>licenseInfo}} + +package {{package}}; + +import com.google.gson.reflect.TypeToken; +{{#imports}}import {{import}}; +{{/imports}} + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +{{/fullJavaUtil}} +import {{invokerPackage}}.JSON; + +import static io.restassured.http.Method.*; + +public class {{classname}} { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private {{classname}}(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static {{classname}} {{classVarName}}(RequestSpecBuilder reqSpec) { + return new {{classname}}(reqSpec); + } + +{{#operations}} +{{#operation}} + + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{operationIdCamelCase}}Oper {{operationId}}() { + return new {{operationIdCamelCase}}Oper(reqSpec); + } +{{/operation}} +{{/operations}} + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return {{classname}} + */ + public {{classname}} setJSON(JSON json) { + this.json = json; + return this; + } + + {{#operations}} + {{#operation}} + /** + * {{summary}} + * {{notes}} + * + {{#allParams}} + * @see #{{#isPathParam}}{{paramName}}Path{{/isPathParam}}{{#isQueryParam}}{{paramName}}Query{{/isQueryParam}}{{#isFormParam}}{{^isFile}}{{paramName}}Form{{/isFile}}{{#isFile}}{{paramName}}MultiPart{{/isFile}}{{/isFormParam}}{{#isHeaderParam}}{{paramName}}Header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/allParams}} + {{#returnType}} + * return {{{returnType}}} + {{/returnType}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public class {{operationIdCamelCase}}Oper { + + public static final String REQ_URI = "{{path}}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public {{operationIdCamelCase}}Oper() { + this.reqSpec = new RequestSpecBuilder(); + {{#vendorExtensions}} + {{#x-contentType}} + reqSpec.setContentType("{{x-contentType}}"); + {{/x-contentType}} + {{#x-accepts}} + reqSpec.setAccept("{{x-accepts}}"); + {{/x-accepts}} + {{/vendorExtensions}} + this.respSpec = new ResponseSpecBuilder(); + } + + public {{operationIdCamelCase}}Oper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + {{#vendorExtensions}} + {{#x-contentType}} + reqSpec.setContentType("{{x-contentType}}"); + {{/x-contentType}} + {{#x-accepts}} + reqSpec.setAccept("{{x-accepts}}"); + {{/x-accepts}} + {{/vendorExtensions}} + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * {{httpMethod}} {{path}} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request({{httpMethod}}, REQ_URI)); + } + {{#returnType}} + + /** + * {{httpMethod}} {{path}} + * @return {{{returnType}}} + */ + public {{{returnType}}} executeAs(Function handler) { + Type type = new TypeToken<{{{returnType}}}>(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + {{/returnType}} + {{#bodyParams}} + + /** + * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + */ + public {{operationIdCamelCase}}Oper body({{{dataType}}} {{paramName}}) { + reqSpec.setBody(getJSON().serialize({{paramName}})); + return this; + } + {{/bodyParams}} + {{#headerParams}} + + /** + * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + */ + public {{operationIdCamelCase}}Oper {{paramName}}Header(String {{paramName}}) { + reqSpec.addHeader("{{baseName}}", {{paramName}}); + return this; + } + {{/headerParams}} + {{#pathParams}} + + /** + * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + */ + public {{operationIdCamelCase}}Oper {{paramName}}Path(Object {{paramName}}) { + reqSpec.addPathParam("{{baseName}}", {{paramName}}); + return this; + } + {{/pathParams}} + {{#queryParams}} + + /** + * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + */ + public {{operationIdCamelCase}}Oper {{paramName}}Query(Object... {{paramName}}) { + reqSpec.addQueryParam("{{baseName}}", {{paramName}}); + return this; + } + {{/queryParams}} + {{#formParams}} + {{^isFile}} + + /** + * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + */ + public {{operationIdCamelCase}}Oper {{paramName}}Form(Object... {{paramName}}) { + reqSpec.addFormParam("{{baseName}}", {{paramName}}); + return this; + } + {{/isFile}} + {{/formParams}} + {{#formParams}} + {{#isFile}} + + /** + * It will assume that the control name is file and the is + * @see #reqSpec for customise + * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + */ + public {{operationIdCamelCase}}Oper {{paramName}}MultiPart({{{dataType}}} {{paramName}}) { + reqSpec.addMultiPart({{paramName}}); + return this; + } + {{/isFile}} + {{/formParams}} + + /** + * Customise request specification + */ + public {{operationIdCamelCase}}Oper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public {{operationIdCamelCase}}Oper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +{{/operation}} +{{/operations}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api_doc.mustache new file mode 100644 index 000000000000..c8bf20319e7c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api_doc.mustache @@ -0,0 +1,62 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes: +//import {{invokerPackage}}.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +{{classname}} api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("{{basePath}}"))).{{classVarName}}(); + +api.{{operationId}}(){{#allParams}}{{#required}}{{#isPathParam}} + .{{paramName}}Path({{paramName}}){{/isPathParam}}{{#isQueryParam}} + .{{paramName}}Query({{paramName}}){{/isQueryParam}}{{#isFormParam}}{{^isFile}} + .{{paramName}}Form({{paramName}}){{/isFile}}{{/isFormParam}}{{#isFormParam}}{{#isFile}} + .{{paramName}}MultiPart({{paramName}}){{/isFile}}{{/isFormParam}}{{#isHeaderParam}} + .{{paramName}}Header({{paramName}}){{/isHeaderParam}}{{#isBodyParam}} + .body({{paramName}}){{/isBodyParam}}{{/required}}{{/allParams}}.execute(r -> r.prettyPeek()); +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api_test.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api_test.mustache new file mode 100644 index 000000000000..5c17db415e3a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/api_test.mustache @@ -0,0 +1,65 @@ +{{>licenseInfo}} + +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +import {{invokerPackage}}.ApiClient; +import {{apiPackage}}.{{classname}}; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import org.junit.Before; +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.restassured.config.RestAssuredConfig.config; +import static {{invokerPackage}}.GsonObjectMapper.gson; + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private {{classname}} api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("{{{basePath}}}"))).{{classVarName}}(); + } +{{#operations}} +{{#operation}} + + {{#responses}} + /** + * {{message}} + */ + @Test + public void shouldSee{{code}}After{{operationIdCamelCase}}() { + {{#allParams}} + {{#isHeaderParam}}String {{paramName}} = null;{{/isHeaderParam}}{{^isHeaderParam}}{{{dataType}}} {{paramName}} = null;{{/isHeaderParam}} + {{/allParams}} + api.{{operationId}}(){{#allParams}}{{#required}}{{#isPathParam}} + .{{paramName}}Path({{paramName}}){{/isPathParam}}{{#isQueryParam}} + .{{paramName}}Query({{paramName}}){{/isQueryParam}}{{#isFormParam}}{{^isFile}} + .{{paramName}}Form({{paramName}}){{/isFile}}{{/isFormParam}}{{#isFormParam}}{{#isFile}} + .{{paramName}}MultiPart({{paramName}}){{/isFile}}{{/isFormParam}}{{#isHeaderParam}} + .{{paramName}}Header({{paramName}}){{/isHeaderParam}}{{#isBodyParam}} + .body({{paramName}}){{/isBodyParam}}{{/required}}{{/allParams}}.execute(r -> r.prettyPeek()); + // TODO: test validations + } + + {{/responses}} +{{/operation}} +{{/operations}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache new file mode 100644 index 000000000000..0b3d148d8654 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache @@ -0,0 +1,122 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + +group = '{{groupId}}' +version = '{{artifactVersion}}' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.5.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 23 + buildToolsVersion '23.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided 'javax.annotation:jsr250-api:1.0' + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + install { + repositories.mavenInstaller { + pom.artifactId = '{{artifactId}}' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + swagger_annotations_version = "1.5.15" + rest_assured_version = "3.0.6" + junit_version = "4.12" + gson_version = "2.6.1" + gson_fire_version = "1.8.2" +{{#joda}} + jodatime_version = "2.9.9" +{{/joda}} +{{#threetenbp}} + threetenbp_version = "1.3.5" +{{/threetenbp}} +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "io.rest-assured:scala-support:$rest_assured_version" + compile "io.gsonfire:gson-fire:$gson_fire_version" +{{#joda}} + compile "joda-time:joda-time:$jodatime_version" + compile 'com.google.code.gson:gson:$gson_version' +{{/joda}} +{{#threetenbp}} + compile "org.threeten:threetenbp:$threetenbp_version" +{{/threetenbp}} + testCompile "junit:junit:$junit_version" +} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache new file mode 100644 index 000000000000..da24a8fdd8c8 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache @@ -0,0 +1,25 @@ +lazy val root = (project in file(".")). + settings( + organization := "{{groupId}}", + name := "{{artifactId}}", + version := "{{artifactVersion}}", + scalaVersion := "2.11.4", + scalacOptions ++= Seq("-feature"), + javacOptions in compile ++= Seq("-Xlint:deprecation"), + publishArtifact in (Compile, packageDoc) := false, + resolvers += Resolver.mavenLocal, + libraryDependencies ++= Seq( + "io.swagger" % "swagger-annotations" % "1.5.15", + "io.rest-assured" % "scala-support" % "3.0.6" + "com.google.code.gson" % "gson" % "2.6.1", + "io.gsonfire" % "gson-fire" % "1.8.2" % "compile", +{{#joda}} + "joda-time" % "joda-time" % "2.9.9" % "compile", +{{/joda}} +{{#threetenbp}} + "org.threeten" % "threetenbp" % "1.3.5" % "compile", +{{/threetenbp}} + "junit" % "junit" % "4.12" % "test", + "com.novocode" % "junit-interface" % "0.10" % "test" + ) + ) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/pom.mustache new file mode 100644 index 000000000000..086980646476 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/rest-assured/pom.mustache @@ -0,0 +1,256 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + {{artifactUrl}} + {{artifactDescription}} + + {{scmConnection}} + {{scmDeveloperConnection}} + {{scmUrl}} + + + + + {{licenseName}} + {{licenseUrl}} + repo + + + + + + {{developerName}} + {{developerEmail}} + {{developerOrganization}} + {{developerOrganizationUrl}} + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + io.swagger + swagger-annotations + ${swagger-core-version} + + + io.rest-assured + rest-assured + ${rest-assured.version} + + + com.google.code.gson + gson + ${gson-version} + + {{#joda}} + + joda-time + joda-time + ${jodatime-version} + + {{/joda}} + {{#threetenbp}} + + org.threeten + threetenbp + ${threetenbp-version} + + {{/threetenbp}} + + io.gsonfire + gson-fire + ${gson-fire-version} + + + + junit + junit + ${junit-version} + test + + + + UTF-8 + 1.5.15 + 3.0.6 + 2.6.1 + 1.8.2 + 1.0.0 + {{#joda}} + 2.9.9 + {{/joda}} + {{#threetenbp}} + 1.3.5 + {{/threetenbp}} + 4.12 + + diff --git a/samples/client/petstore/java/rest-assured/.gitignore b/samples/client/petstore/java/rest-assured/.gitignore new file mode 100644 index 000000000000..a530464afa1b --- /dev/null +++ b/samples/client/petstore/java/rest-assured/.gitignore @@ -0,0 +1,21 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/rest-assured/.swagger-codegen-ignore b/samples/client/petstore/java/rest-assured/.swagger-codegen-ignore new file mode 100644 index 000000000000..c5fa491b4c55 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/java/rest-assured/.swagger-codegen/VERSION b/samples/client/petstore/java/rest-assured/.swagger-codegen/VERSION new file mode 100644 index 000000000000..855ff9501eb8 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/.travis.yml b/samples/client/petstore/java/rest-assured/.travis.yml new file mode 100644 index 000000000000..70cb81a67c20 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/.travis.yml @@ -0,0 +1,17 @@ +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# +language: java +jdk: + - oraclejdk8 + - oraclejdk7 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + - mvn test + # uncomment below to test using gradle + # - gradle test + # uncomment below to test using sbt + # - sbt test diff --git a/samples/client/petstore/java/rest-assured/README.md b/samples/client/petstore/java/rest-assured/README.md new file mode 100644 index 000000000000..42dbb94813b7 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/README.md @@ -0,0 +1,43 @@ +# swagger-petstore-rest-assured + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation & Usage + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: + +```xml + + io.swagger + swagger-petstore-rest-assured + 1.0.0 + compile + + +``` + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. + +## Author + +apiteam@swagger.io + + diff --git a/samples/client/petstore/java/rest-assured/build.gradle b/samples/client/petstore/java/rest-assured/build.gradle new file mode 100644 index 000000000000..7f6177babb85 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/build.gradle @@ -0,0 +1,111 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + +group = 'io.swagger' +version = '1.0.0' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.5.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + } +} + +repositories { + jcenter() +} + + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 23 + buildToolsVersion '23.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 22 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided 'javax.annotation:jsr250-api:1.0' + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + install { + repositories.mavenInstaller { + pom.artifactId = 'swagger-petstore-rest-assured' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + swagger_annotations_version = "1.5.15" + rest_assured_version = "3.0.6" + junit_version = "4.12" + gson_version = "2.6.1" + gson_fire_version = "1.8.2" + threetenbp_version = "1.3.5" +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "io.rest-assured:scala-support:$rest_assured_version" + compile "io.gsonfire:gson-fire:$gson_fire_version" + compile "org.threeten:threetenbp:$threetenbp_version" + testCompile "junit:junit:$junit_version" +} diff --git a/samples/client/petstore/java/rest-assured/build.sbt b/samples/client/petstore/java/rest-assured/build.sbt new file mode 100644 index 000000000000..13a2cedb077c --- /dev/null +++ b/samples/client/petstore/java/rest-assured/build.sbt @@ -0,0 +1,20 @@ +lazy val root = (project in file(".")). + settings( + organization := "io.swagger", + name := "swagger-petstore-rest-assured", + version := "1.0.0", + scalaVersion := "2.11.4", + scalacOptions ++= Seq("-feature"), + javacOptions in compile ++= Seq("-Xlint:deprecation"), + publishArtifact in (Compile, packageDoc) := false, + resolvers += Resolver.mavenLocal, + libraryDependencies ++= Seq( + "io.swagger" % "swagger-annotations" % "1.5.15", + "io.rest-assured" % "scala-support" % "3.0.6" + "com.google.code.gson" % "gson" % "2.6.1", + "io.gsonfire" % "gson-fire" % "1.8.2" % "compile", + "org.threeten" % "threetenbp" % "1.3.5" % "compile", + "junit" % "junit" % "4.12" % "test", + "com.novocode" % "junit-interface" % "0.10" % "test" + ) + ) diff --git a/samples/client/petstore/java/rest-assured/docs/AdditionalPropertiesClass.md b/samples/client/petstore/java/rest-assured/docs/AdditionalPropertiesClass.md new file mode 100644 index 000000000000..0437c4dd8cc7 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/AdditionalPropertiesClass.md @@ -0,0 +1,11 @@ + +# AdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapProperty** | **Map<String, String>** | | [optional] +**mapOfMapProperty** | [**Map<String, Map<String, String>>**](Map.md) | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Animal.md b/samples/client/petstore/java/rest-assured/docs/Animal.md new file mode 100644 index 000000000000..b3f325c3524d --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Animal.md @@ -0,0 +1,11 @@ + +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**color** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/AnimalFarm.md b/samples/client/petstore/java/rest-assured/docs/AnimalFarm.md new file mode 100644 index 000000000000..c7c7f1ddcce6 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/AnimalFarm.md @@ -0,0 +1,9 @@ + +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + + diff --git a/samples/client/petstore/java/rest-assured/docs/AnotherFakeApi.md b/samples/client/petstore/java/rest-assured/docs/AnotherFakeApi.md new file mode 100644 index 000000000000..e26468a5fd8b --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/AnotherFakeApi.md @@ -0,0 +1,51 @@ +# AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags + + + +# **testSpecialTags** +> Client testSpecialTags(body) + +To test special tags + +To test special tags + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +AnotherFakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).anotherFake(); + +api.testSpecialTags() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + diff --git a/samples/client/petstore/java/rest-assured/docs/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/java/rest-assured/docs/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 000000000000..772925499274 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,10 @@ + +# ArrayOfArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayArrayNumber** | [**List<List<BigDecimal>>**](List.md) | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/ArrayOfNumberOnly.md b/samples/client/petstore/java/rest-assured/docs/ArrayOfNumberOnly.md new file mode 100644 index 000000000000..e8cc4cd36dc0 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ArrayOfNumberOnly.md @@ -0,0 +1,10 @@ + +# ArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayNumber** | [**List<BigDecimal>**](BigDecimal.md) | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/ArrayTest.md b/samples/client/petstore/java/rest-assured/docs/ArrayTest.md new file mode 100644 index 000000000000..9feee16427fb --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ArrayTest.md @@ -0,0 +1,12 @@ + +# ArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayOfString** | **List<String>** | | [optional] +**arrayArrayOfInteger** | [**List<List<Long>>**](List.md) | | [optional] +**arrayArrayOfModel** | [**List<List<ReadOnlyFirst>>**](List.md) | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Capitalization.md b/samples/client/petstore/java/rest-assured/docs/Capitalization.md new file mode 100644 index 000000000000..0f3064c1996f --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Capitalization.md @@ -0,0 +1,15 @@ + +# Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**smallCamel** | **String** | | [optional] +**capitalCamel** | **String** | | [optional] +**smallSnake** | **String** | | [optional] +**capitalSnake** | **String** | | [optional] +**scAETHFlowPoints** | **String** | | [optional] +**ATT_NAME** | **String** | Name of the pet | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Cat.md b/samples/client/petstore/java/rest-assured/docs/Cat.md new file mode 100644 index 000000000000..6e9f71ce7dd0 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Cat.md @@ -0,0 +1,10 @@ + +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Category.md b/samples/client/petstore/java/rest-assured/docs/Category.md new file mode 100644 index 000000000000..e2df08032787 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/ClassModel.md b/samples/client/petstore/java/rest-assured/docs/ClassModel.md new file mode 100644 index 000000000000..64f880c87869 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ClassModel.md @@ -0,0 +1,10 @@ + +# ClassModel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**propertyClass** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Client.md b/samples/client/petstore/java/rest-assured/docs/Client.md new file mode 100644 index 000000000000..5c490ea166c7 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Client.md @@ -0,0 +1,10 @@ + +# Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Dog.md b/samples/client/petstore/java/rest-assured/docs/Dog.md new file mode 100644 index 000000000000..ac7cea323ffd --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Dog.md @@ -0,0 +1,10 @@ + +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/EnumArrays.md b/samples/client/petstore/java/rest-assured/docs/EnumArrays.md new file mode 100644 index 000000000000..4dddc0bfd27b --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/EnumArrays.md @@ -0,0 +1,27 @@ + +# EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**justSymbol** | [**JustSymbolEnum**](#JustSymbolEnum) | | [optional] +**arrayEnum** | [**List<ArrayEnumEnum>**](#List<ArrayEnumEnum>) | | [optional] + + + +## Enum: JustSymbolEnum +Name | Value +---- | ----- +GREATER_THAN_OR_EQUAL_TO | ">=" +DOLLAR | "$" + + + +## Enum: List<ArrayEnumEnum> +Name | Value +---- | ----- +FISH | "fish" +CRAB | "crab" + + + diff --git a/samples/client/petstore/java/rest-assured/docs/EnumClass.md b/samples/client/petstore/java/rest-assured/docs/EnumClass.md new file mode 100644 index 000000000000..c746edc3cb1e --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/EnumClass.md @@ -0,0 +1,14 @@ + +# EnumClass + +## Enum + + +* `_ABC` (value: `"_abc"`) + +* `_EFG` (value: `"-efg"`) + +* `_XYZ_` (value: `"(xyz)"`) + + + diff --git a/samples/client/petstore/java/rest-assured/docs/EnumTest.md b/samples/client/petstore/java/rest-assured/docs/EnumTest.md new file mode 100644 index 000000000000..08fee3448821 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/EnumTest.md @@ -0,0 +1,38 @@ + +# EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional] +**enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional] +**enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional] +**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional] + + + +## Enum: EnumStringEnum +Name | Value +---- | ----- +UPPER | "UPPER" +LOWER | "lower" +EMPTY | "" + + + +## Enum: EnumIntegerEnum +Name | Value +---- | ----- +NUMBER_1 | 1 +NUMBER_MINUS_1 | -1 + + + +## Enum: EnumNumberEnum +Name | Value +---- | ----- +NUMBER_1_DOT_1 | 1.1 +NUMBER_MINUS_1_DOT_2 | -1.2 + + + diff --git a/samples/client/petstore/java/rest-assured/docs/FakeApi.md b/samples/client/petstore/java/rest-assured/docs/FakeApi.md new file mode 100644 index 000000000000..f2d9bd569cd5 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/FakeApi.md @@ -0,0 +1,415 @@ +# FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | +[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | +[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | +[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | +[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + + + +# **fakeOuterBooleanSerialize** +> Boolean fakeOuterBooleanSerialize(body) + + + +Test serialization of outer boolean types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.fakeOuterBooleanSerialize().execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Boolean**](Boolean.md)| Input boolean as post body | [optional] + +### Return type + +**Boolean** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterCompositeSerialize** +> OuterComposite fakeOuterCompositeSerialize(body) + + + +Test serialization of object with outer number type + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.fakeOuterCompositeSerialize().execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterNumberSerialize** +> BigDecimal fakeOuterNumberSerialize(body) + + + +Test serialization of outer number types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.fakeOuterNumberSerialize().execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**BigDecimal**](BigDecimal.md)| Input number as post body | [optional] + +### Return type + +[**BigDecimal**](BigDecimal.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterStringSerialize** +> String fakeOuterStringSerialize(body) + + + +Test serialization of outer string types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.fakeOuterStringSerialize().execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**String**](String.md)| Input string as post body | [optional] + +### Return type + +**String** + +### 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 +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.testClientModel() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +# **testEndpointParameters** +> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.testEndpointParameters() + .numberForm(number) + ._doubleForm(_double) + .patternWithoutDelimiterForm(patternWithoutDelimiter) + ._byteForm(_byte).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **BigDecimal**| None | + **_double** | **Double**| None | + **patternWithoutDelimiter** | **String**| None | + **_byte** | **byte[]**| None | + **integer** | **Integer**| None | [optional] + **int32** | **Integer**| None | [optional] + **int64** | **Long**| None | [optional] + **_float** | **Float**| None | [optional] + **string** | **String**| None | [optional] + **binary** | **byte[]**| None | [optional] + **date** | **LocalDate**| None | [optional] + **dateTime** | **OffsetDateTime**| None | [optional] + **password** | **String**| None | [optional] + **paramCallback** | **String**| None | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### 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(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble) + +To test enum parameters + +To test enum parameters + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.testEnumParameters().execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enumFormStringArray** | [**List<String>**](String.md)| Form parameter enum test (string array) | [optional] [enum: >, $] + **enumFormString** | **String**| Form parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] + **enumHeaderStringArray** | [**List<String>**](String.md)| Header parameter enum test (string array) | [optional] [enum: >, $] + **enumHeaderString** | **String**| Header parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] + **enumQueryStringArray** | [**List<String>**](String.md)| Query parameter enum test (string array) | [optional] [enum: >, $] + **enumQueryString** | **String**| Query parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] + **enumQueryInteger** | **Integer**| Query parameter enum test (double) | [optional] [enum: 1, -2] + **enumQueryDouble** | **Double**| Query parameter enum test (double) | [optional] [enum: 1.1, -1.2] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: */* + - **Accept**: */* + + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.testInlineAdditionalProperties() + .body(param).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **testJsonFormData** +> testJsonFormData(param, param2) + +test json serialization of form data + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + +api.testJsonFormData() + .paramForm(param) + .param2Form(param2).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **String**| field1 | + **param2** | **String**| field2 | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + diff --git a/samples/client/petstore/java/rest-assured/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/rest-assured/docs/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..dcedef8fb0b1 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/FakeClassnameTags123Api.md @@ -0,0 +1,49 @@ +# FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + + +# **testClassname** +> Client testClassname(body) + +To test class name in snake case + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +FakeClassnameTags123Api api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).fakeClassnameTags123(); + +api.testClassname() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + diff --git a/samples/client/petstore/java/rest-assured/docs/FormatTest.md b/samples/client/petstore/java/rest-assured/docs/FormatTest.md new file mode 100644 index 000000000000..c7a3acb3cb7e --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/FormatTest.md @@ -0,0 +1,22 @@ + +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **Integer** | | [optional] +**int32** | **Integer** | | [optional] +**int64** | **Long** | | [optional] +**number** | [**BigDecimal**](BigDecimal.md) | | +**_float** | **Float** | | [optional] +**_double** | **Double** | | [optional] +**string** | **String** | | [optional] +**_byte** | **byte[]** | | +**binary** | **byte[]** | | [optional] +**date** | [**LocalDate**](LocalDate.md) | | +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] +**uuid** | [**UUID**](UUID.md) | | [optional] +**password** | **String** | | + + + diff --git a/samples/client/petstore/java/rest-assured/docs/HasOnlyReadOnly.md b/samples/client/petstore/java/rest-assured/docs/HasOnlyReadOnly.md new file mode 100644 index 000000000000..c1d0aac56728 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/HasOnlyReadOnly.md @@ -0,0 +1,11 @@ + +# HasOnlyReadOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **String** | | [optional] +**foo** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/MapTest.md b/samples/client/petstore/java/rest-assured/docs/MapTest.md new file mode 100644 index 000000000000..714a97a40d93 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/MapTest.md @@ -0,0 +1,19 @@ + +# MapTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapMapOfString** | [**Map<String, Map<String, String>>**](Map.md) | | [optional] +**mapOfEnumString** | [**Map<String, InnerEnum>**](#Map<String, InnerEnum>) | | [optional] + + + +## Enum: Map<String, InnerEnum> +Name | Value +---- | ----- +UPPER | "UPPER" +LOWER | "lower" + + + diff --git a/samples/client/petstore/java/rest-assured/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/rest-assured/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 000000000000..b12e2cd70e69 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,12 @@ + +# MixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | [**UUID**](UUID.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] +**map** | [**Map<String, Animal>**](Animal.md) | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Model200Response.md b/samples/client/petstore/java/rest-assured/docs/Model200Response.md new file mode 100644 index 000000000000..5b3a9a0e46da --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Model200Response.md @@ -0,0 +1,11 @@ + +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] +**propertyClass** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/ModelApiResponse.md b/samples/client/petstore/java/rest-assured/docs/ModelApiResponse.md new file mode 100644 index 000000000000..3eec8686cc95 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ + +# ModelApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/ModelReturn.md b/samples/client/petstore/java/rest-assured/docs/ModelReturn.md new file mode 100644 index 000000000000..a679b04953e5 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ModelReturn.md @@ -0,0 +1,10 @@ + +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Name.md b/samples/client/petstore/java/rest-assured/docs/Name.md new file mode 100644 index 000000000000..ce2fb4dee50c --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Name.md @@ -0,0 +1,13 @@ + +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | +**snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] +**_123Number** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/NumberOnly.md b/samples/client/petstore/java/rest-assured/docs/NumberOnly.md new file mode 100644 index 000000000000..a3feac7fadc5 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/NumberOnly.md @@ -0,0 +1,10 @@ + +# NumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**justNumber** | [**BigDecimal**](BigDecimal.md) | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Order.md b/samples/client/petstore/java/rest-assured/docs/Order.md new file mode 100644 index 000000000000..268c617d1ff1 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Order.md @@ -0,0 +1,24 @@ + +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**petId** | **Long** | | [optional] +**quantity** | **Integer** | | [optional] +**shipDate** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] +**complete** | **Boolean** | | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +PLACED | "placed" +APPROVED | "approved" +DELIVERED | "delivered" + + + diff --git a/samples/client/petstore/java/rest-assured/docs/OuterComposite.md b/samples/client/petstore/java/rest-assured/docs/OuterComposite.md new file mode 100644 index 000000000000..3f5a633c998e --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/OuterComposite.md @@ -0,0 +1,12 @@ + +# OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**myNumber** | [**BigDecimal**](BigDecimal.md) | | [optional] +**myString** | **String** | | [optional] +**myBoolean** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/OuterEnum.md b/samples/client/petstore/java/rest-assured/docs/OuterEnum.md new file mode 100644 index 000000000000..ed2cb206789b --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/OuterEnum.md @@ -0,0 +1,14 @@ + +# OuterEnum + +## Enum + + +* `PLACED` (value: `"placed"`) + +* `APPROVED` (value: `"approved"`) + +* `DELIVERED` (value: `"delivered"`) + + + diff --git a/samples/client/petstore/java/rest-assured/docs/Pet.md b/samples/client/petstore/java/rest-assured/docs/Pet.md new file mode 100644 index 000000000000..5b63109ef924 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Pet.md @@ -0,0 +1,24 @@ + +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **List<String>** | | +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +AVAILABLE | "available" +PENDING | "pending" +SOLD | "sold" + + + diff --git a/samples/client/petstore/java/rest-assured/docs/PetApi.md b/samples/client/petstore/java/rest-assured/docs/PetApi.md new file mode 100644 index 000000000000..8e2fd4fa00ee --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/PetApi.md @@ -0,0 +1,357 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **addPet** +> addPet(body) + +Add a new pet to the store + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.addPet() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.deletePet() + .petIdPath(petId).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByStatus** +> List<Pet> findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.findPetsByStatus() + .statusQuery(status).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> List<Pet> findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.findPetsByTags() + .tagsQuery(tags).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.getPetById() + .petIdPath(petId).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updatePet** +> updatePet(body) + +Update an existing pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.updatePet() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.updatePetWithForm() + .petIdPath(petId).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + + +# **uploadFile** +> ModelApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +PetApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + +api.uploadFile() + .petIdPath(petId).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/rest-assured/docs/ReadOnlyFirst.md b/samples/client/petstore/java/rest-assured/docs/ReadOnlyFirst.md new file mode 100644 index 000000000000..426b7cde95ab --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ReadOnlyFirst.md @@ -0,0 +1,11 @@ + +# ReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **String** | | [optional] +**baz** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/SpecialModelName.md b/samples/client/petstore/java/rest-assured/docs/SpecialModelName.md new file mode 100644 index 000000000000..c2c6117c552c --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/SpecialModelName.md @@ -0,0 +1,10 @@ + +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**specialPropertyName** | **Long** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/StoreApi.md b/samples/client/petstore/java/rest-assured/docs/StoreApi.md new file mode 100644 index 000000000000..aa3529f0d996 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/StoreApi.md @@ -0,0 +1,176 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +StoreApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).store(); + +api.deleteOrder() + .orderIdPath(orderId).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getInventory** +> Map<String, Integer> getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +StoreApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).store(); + +api.getInventory().execute(r -> r.prettyPeek()); +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Map<String, Integer>** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +StoreApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).store(); + +api.getOrderById() + .orderIdPath(orderId).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **Long**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +StoreApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).store(); + +api.placeOrder() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/rest-assured/docs/Tag.md b/samples/client/petstore/java/rest-assured/docs/Tag.md new file mode 100644 index 000000000000..de6814b55d57 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/User.md b/samples/client/petstore/java/rest-assured/docs/User.md new file mode 100644 index 000000000000..8b6753dd284a --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/User.md @@ -0,0 +1,17 @@ + +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**username** | **String** | | [optional] +**firstName** | **String** | | [optional] +**lastName** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**userStatus** | **Integer** | User Status | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/UserApi.md b/samples/client/petstore/java/rest-assured/docs/UserApi.md new file mode 100644 index 000000000000..1746a18167f3 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/UserApi.md @@ -0,0 +1,352 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.createUser() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.createUsersWithArrayInput() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.createUsersWithListInput() + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.deleteUser() + .usernamePath(username).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.getUserByName() + .usernamePath(username).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **loginUser** +> String loginUser(username, password) + +Logs user into the system + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.loginUser() + .usernameQuery(username) + .passwordQuery(password).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.logoutUser().execute(r -> r.prettyPeek()); +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.filter.log.ErrorLoggingFilter; + +UserApi api = ApiClient.api(ApiClient.Config.apiConfig().withReqSpecSupplier( + () -> new RequestSpecBuilder() + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + +api.updateUser() + .usernamePath(username) + .body(body).execute(r -> r.prettyPeek()); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/rest-assured/git_push.sh b/samples/client/petstore/java/rest-assured/git_push.sh new file mode 100644 index 000000000000..ae01b182ae9e --- /dev/null +++ b/samples/client/petstore/java/rest-assured/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/java/rest-assured/gradle.properties b/samples/client/petstore/java/rest-assured/gradle.properties new file mode 100644 index 000000000000..05644f0754af --- /dev/null +++ b/samples/client/petstore/java/rest-assured/gradle.properties @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/java/rest-assured/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..2c6137b87896 Binary files /dev/null and b/samples/client/petstore/java/rest-assured/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/java/rest-assured/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/java/rest-assured/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..b7a364739551 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue May 17 23:08:05 CST 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip diff --git a/samples/client/petstore/java/rest-assured/gradlew b/samples/client/petstore/java/rest-assured/gradlew new file mode 100644 index 000000000000..9d82f7891513 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/samples/client/petstore/java/rest-assured/gradlew.bat b/samples/client/petstore/java/rest-assured/gradlew.bat new file mode 100644 index 000000000000..5f192121eb4f --- /dev/null +++ b/samples/client/petstore/java/rest-assured/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/java/rest-assured/pom.xml b/samples/client/petstore/java/rest-assured/pom.xml new file mode 100644 index 000000000000..511e863f081f --- /dev/null +++ b/samples/client/petstore/java/rest-assured/pom.xml @@ -0,0 +1,242 @@ + + 4.0.0 + io.swagger + swagger-petstore-rest-assured + jar + swagger-petstore-rest-assured + 1.0.0 + https://github.com/swagger-api/swagger-codegen + Swagger Java + + scm:git:git@github.com:swagger-api/swagger-codegen.git + scm:git:git@github.com:swagger-api/swagger-codegen.git + https://github.com/swagger-api/swagger-codegen + + + + + Unlicense + http://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + + Swagger + apiteam@swagger.io + Swagger + http://swagger.io + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + io.swagger + swagger-annotations + ${swagger-core-version} + + + io.rest-assured + rest-assured + ${rest-assured.version} + + + com.google.code.gson + gson + ${gson-version} + + + org.threeten + threetenbp + ${threetenbp-version} + + + io.gsonfire + gson-fire + ${gson-fire-version} + + + + junit + junit + ${junit-version} + test + + + + UTF-8 + 1.5.15 + 3.0.6 + 2.6.1 + 1.8.2 + 1.0.0 + 1.3.5 + 4.12 + + diff --git a/samples/client/petstore/java/rest-assured/settings.gradle b/samples/client/petstore/java/rest-assured/settings.gradle new file mode 100644 index 000000000000..4d5d47521768 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "swagger-petstore-rest-assured" \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/AndroidManifest.xml b/samples/client/petstore/java/rest-assured/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..465dcb520c40 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/ApiClient.java new file mode 100644 index 000000000000..f8f8fc93aaf7 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/ApiClient.java @@ -0,0 +1,77 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import io.swagger.client.api.*; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +public class ApiClient { + + private final Config config; + + private ApiClient(Config config) { + this.config = config; + } + + public static ApiClient api(Config config) { + return new ApiClient(config); + } + + public AnotherFakeApi anotherFake() { + return AnotherFakeApi.anotherFake(config.baseReqSpec.get()); + } + public FakeApi fake() { + return FakeApi.fake(config.baseReqSpec.get()); + } + public FakeClassnameTags123Api fakeClassnameTags123() { + return FakeClassnameTags123Api.fakeClassnameTags123(config.baseReqSpec.get()); + } + public PetApi pet() { + return PetApi.pet(config.baseReqSpec.get()); + } + public StoreApi store() { + return StoreApi.store(config.baseReqSpec.get()); + } + public UserApi user() { + return UserApi.user(config.baseReqSpec.get()); + } + + public static class Config { + private Supplier baseReqSpec; + + /** + * Use common specification for all operations + */ + public Config reqSpecSupplier(Supplier supplier) { + this.baseReqSpec = supplier; + return this; + } + + public static Config apiConfig() { + return new Config(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/GsonObjectMapper.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/GsonObjectMapper.java new file mode 100644 index 000000000000..ce4190ea35ef --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/GsonObjectMapper.java @@ -0,0 +1,41 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import io.restassured.mapper.ObjectMapper; +import io.restassured.mapper.ObjectMapperDeserializationContext; +import io.restassured.mapper.ObjectMapperSerializationContext; + +public class GsonObjectMapper implements ObjectMapper { + + private JSON json; + + private GsonObjectMapper() { + this.json = new JSON(); + } + + public static GsonObjectMapper gson() { + return new GsonObjectMapper(); + } + + @Override + public Object deserialize(ObjectMapperDeserializationContext context) { + return json.deserialize(context.getDataToDeserialize().asString(), context.getType()); + } + + @Override + public Object serialize(ObjectMapperSerializationContext context) { + return json.serialize(context.getObjectToSerialize()); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/JSON.java new file mode 100644 index 000000000000..df84d970239b --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/JSON.java @@ -0,0 +1,374 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; + +import io.swagger.client.model.*; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.util.Date; +import java.util.Map; +import java.util.HashMap; + +public class JSON { + private Gson gson; + private boolean isLenientOnJson = false; + private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + .registerTypeSelector(Animal.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("Cat".toUpperCase(), Cat.class); + classByDiscriminatorValue.put("Dog".toUpperCase(), Dog.class); + classByDiscriminatorValue.put("Animal".toUpperCase(), Animal.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "className")); + } + }) + ; + return fireBuilder.createGsonBuilder(); + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if(null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase()); + if(null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + public JSON() { + gson = createGson() + .registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) + .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) + .create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + * @return JSON + */ + public JSON setGson(Gson gson) { + this.gson = gson; + return this; + } + + public JSON setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + return this; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) + return (T) body; + else throw (e); + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + return this; + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() { + } + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() { + } + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public JSON setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + return this; + } + +} diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/ResponseSpecBuilders.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/ResponseSpecBuilders.java new file mode 100644 index 000000000000..8feefa1bd35a --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/ResponseSpecBuilders.java @@ -0,0 +1,42 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; +import io.restassured.specification.ResponseSpecification; + +import java.util.function.Function; + +public class ResponseSpecBuilders { + + private ResponseSpecBuilders() { + } + + public static Function validatedWith(ResponseSpecification respSpec) { + return response -> response.then().spec(respSpec).extract().response(); + } + + public static Function validatedWith(ResponseSpecBuilder respSpec) { + return validatedWith(respSpec.build()); + } + + /** + * @param code expected status code + * @return ResponseSpecBuilder + */ + public static ResponseSpecBuilder shouldBeCode(int code) { + return new ResponseSpecBuilder().expectStatusCode(code); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/AnotherFakeApi.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/AnotherFakeApi.java new file mode 100644 index 000000000000..42c71810a905 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/AnotherFakeApi.java @@ -0,0 +1,146 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import com.google.gson.reflect.TypeToken; +import io.swagger.client.model.Client; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import io.swagger.client.JSON; + +import static io.restassured.http.Method.*; + +public class AnotherFakeApi { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private AnotherFakeApi(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static AnotherFakeApi anotherFake(RequestSpecBuilder reqSpec) { + return new AnotherFakeApi(reqSpec); + } + + + public TestSpecialTagsOper testSpecialTags() { + return new TestSpecialTagsOper(reqSpec); + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return AnotherFakeApi + */ + public AnotherFakeApi setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * To test special tags + * To test special tags + * + * @see #body client model (required) + * return Client + */ + public class TestSpecialTagsOper { + + public static final String REQ_URI = "/another-fake/dummy"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestSpecialTagsOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestSpecialTagsOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * PATCH /another-fake/dummy + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(PATCH, REQ_URI)); + } + + /** + * PATCH /another-fake/dummy + * @return Client + */ + public Client executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (Client) client model (required) + */ + public TestSpecialTagsOper body(Client body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public TestSpecialTagsOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestSpecialTagsOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/FakeApi.java new file mode 100644 index 000000000000..21b2dd3e589c --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/FakeApi.java @@ -0,0 +1,883 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import com.google.gson.reflect.TypeToken; +import java.math.BigDecimal; +import io.swagger.client.model.Client; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import io.swagger.client.model.OuterComposite; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import io.swagger.client.JSON; + +import static io.restassured.http.Method.*; + +public class FakeApi { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private FakeApi(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static FakeApi fake(RequestSpecBuilder reqSpec) { + return new FakeApi(reqSpec); + } + + + public FakeOuterBooleanSerializeOper fakeOuterBooleanSerialize() { + return new FakeOuterBooleanSerializeOper(reqSpec); + } + + public FakeOuterCompositeSerializeOper fakeOuterCompositeSerialize() { + return new FakeOuterCompositeSerializeOper(reqSpec); + } + + public FakeOuterNumberSerializeOper fakeOuterNumberSerialize() { + return new FakeOuterNumberSerializeOper(reqSpec); + } + + public FakeOuterStringSerializeOper fakeOuterStringSerialize() { + return new FakeOuterStringSerializeOper(reqSpec); + } + + public TestClientModelOper testClientModel() { + return new TestClientModelOper(reqSpec); + } + + public TestEndpointParametersOper testEndpointParameters() { + return new TestEndpointParametersOper(reqSpec); + } + + public TestEnumParametersOper testEnumParameters() { + return new TestEnumParametersOper(reqSpec); + } + + public TestInlineAdditionalPropertiesOper testInlineAdditionalProperties() { + return new TestInlineAdditionalPropertiesOper(reqSpec); + } + + public TestJsonFormDataOper testJsonFormData() { + return new TestJsonFormDataOper(reqSpec); + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return FakeApi + */ + public FakeApi setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * + * Test serialization of outer boolean types + * + * @see #body Input boolean as post body (optional) + * return Boolean + */ + public class FakeOuterBooleanSerializeOper { + + public static final String REQ_URI = "/fake/outer/boolean"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public FakeOuterBooleanSerializeOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public FakeOuterBooleanSerializeOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /fake/outer/boolean + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /fake/outer/boolean + * @return Boolean + */ + public Boolean executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (Boolean) Input boolean as post body (optional) + */ + public FakeOuterBooleanSerializeOper body(Boolean body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public FakeOuterBooleanSerializeOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public FakeOuterBooleanSerializeOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * + * Test serialization of object with outer number type + * + * @see #body Input composite as post body (optional) + * return OuterComposite + */ + public class FakeOuterCompositeSerializeOper { + + public static final String REQ_URI = "/fake/outer/composite"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public FakeOuterCompositeSerializeOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public FakeOuterCompositeSerializeOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /fake/outer/composite + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /fake/outer/composite + * @return OuterComposite + */ + public OuterComposite executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (OuterComposite) Input composite as post body (optional) + */ + public FakeOuterCompositeSerializeOper body(OuterComposite body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public FakeOuterCompositeSerializeOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public FakeOuterCompositeSerializeOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * + * Test serialization of outer number types + * + * @see #body Input number as post body (optional) + * return BigDecimal + */ + public class FakeOuterNumberSerializeOper { + + public static final String REQ_URI = "/fake/outer/number"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public FakeOuterNumberSerializeOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public FakeOuterNumberSerializeOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /fake/outer/number + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /fake/outer/number + * @return BigDecimal + */ + public BigDecimal executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (BigDecimal) Input number as post body (optional) + */ + public FakeOuterNumberSerializeOper body(BigDecimal body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public FakeOuterNumberSerializeOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public FakeOuterNumberSerializeOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * + * Test serialization of outer string types + * + * @see #body Input string as post body (optional) + * return String + */ + public class FakeOuterStringSerializeOper { + + public static final String REQ_URI = "/fake/outer/string"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public FakeOuterStringSerializeOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public FakeOuterStringSerializeOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /fake/outer/string + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /fake/outer/string + * @return String + */ + public String executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (String) Input string as post body (optional) + */ + public FakeOuterStringSerializeOper body(String body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public FakeOuterStringSerializeOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public FakeOuterStringSerializeOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * To test \"client\" model + * To test \"client\" model + * + * @see #body client model (required) + * return Client + */ + public class TestClientModelOper { + + public static final String REQ_URI = "/fake"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestClientModelOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestClientModelOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * PATCH /fake + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(PATCH, REQ_URI)); + } + + /** + * PATCH /fake + * @return Client + */ + public Client executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (Client) client model (required) + */ + public TestClientModelOper body(Client body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public TestClientModelOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestClientModelOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @see #numberForm None (required) + * @see #_doubleForm None (required) + * @see #patternWithoutDelimiterForm None (required) + * @see #_byteForm None (required) + * @see #integerForm None (optional) + * @see #int32Form None (optional) + * @see #int64Form None (optional) + * @see #_floatForm None (optional) + * @see #stringForm None (optional) + * @see #binaryForm None (optional) + * @see #dateForm None (optional) + * @see #dateTimeForm None (optional) + * @see #passwordForm None (optional) + * @see #paramCallbackForm None (optional) + */ + public class TestEndpointParametersOper { + + public static final String REQ_URI = "/fake"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestEndpointParametersOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/xml; charset=utf-8"); + reqSpec.setAccept("application/xml; charset=utf-8,application/json; charset=utf-8"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestEndpointParametersOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/xml; charset=utf-8"); + reqSpec.setAccept("application/xml; charset=utf-8,application/json; charset=utf-8"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /fake + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param integer (Integer) None (optional) + */ + public TestEndpointParametersOper integerForm(Object... integer) { + reqSpec.addFormParam("integer", integer); + return this; + } + + /** + * @param int32 (Integer) None (optional) + */ + public TestEndpointParametersOper int32Form(Object... int32) { + reqSpec.addFormParam("int32", int32); + return this; + } + + /** + * @param int64 (Long) None (optional) + */ + public TestEndpointParametersOper int64Form(Object... int64) { + reqSpec.addFormParam("int64", int64); + return this; + } + + /** + * @param number (BigDecimal) None (required) + */ + public TestEndpointParametersOper numberForm(Object... number) { + reqSpec.addFormParam("number", number); + return this; + } + + /** + * @param _float (Float) None (optional) + */ + public TestEndpointParametersOper _floatForm(Object... _float) { + reqSpec.addFormParam("float", _float); + return this; + } + + /** + * @param _double (Double) None (required) + */ + public TestEndpointParametersOper _doubleForm(Object... _double) { + reqSpec.addFormParam("double", _double); + return this; + } + + /** + * @param string (String) None (optional) + */ + public TestEndpointParametersOper stringForm(Object... string) { + reqSpec.addFormParam("string", string); + return this; + } + + /** + * @param patternWithoutDelimiter (String) None (required) + */ + public TestEndpointParametersOper patternWithoutDelimiterForm(Object... patternWithoutDelimiter) { + reqSpec.addFormParam("pattern_without_delimiter", patternWithoutDelimiter); + return this; + } + + /** + * @param _byte (byte[]) None (required) + */ + public TestEndpointParametersOper _byteForm(Object... _byte) { + reqSpec.addFormParam("byte", _byte); + return this; + } + + /** + * @param binary (byte[]) None (optional) + */ + public TestEndpointParametersOper binaryForm(Object... binary) { + reqSpec.addFormParam("binary", binary); + return this; + } + + /** + * @param date (LocalDate) None (optional) + */ + public TestEndpointParametersOper dateForm(Object... date) { + reqSpec.addFormParam("date", date); + return this; + } + + /** + * @param dateTime (OffsetDateTime) None (optional) + */ + public TestEndpointParametersOper dateTimeForm(Object... dateTime) { + reqSpec.addFormParam("dateTime", dateTime); + return this; + } + + /** + * @param password (String) None (optional) + */ + public TestEndpointParametersOper passwordForm(Object... password) { + reqSpec.addFormParam("password", password); + return this; + } + + /** + * @param paramCallback (String) None (optional) + */ + public TestEndpointParametersOper paramCallbackForm(Object... paramCallback) { + reqSpec.addFormParam("callback", paramCallback); + return this; + } + + /** + * Customise request specification + */ + public TestEndpointParametersOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestEndpointParametersOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * To test enum parameters + * To test enum parameters + * + * @see #enumFormStringArrayForm Form parameter enum test (string array) (optional) + * @see #enumFormStringForm Form parameter enum test (string) (optional, default to -efg) + * @see #enumHeaderStringArrayHeader Header parameter enum test (string array) (optional) + * @see #enumHeaderStringHeader Header parameter enum test (string) (optional, default to -efg) + * @see #enumQueryStringArrayQuery Query parameter enum test (string array) (optional) + * @see #enumQueryStringQuery Query parameter enum test (string) (optional, default to -efg) + * @see #enumQueryIntegerQuery Query parameter enum test (double) (optional) + * @see #enumQueryDoubleForm Query parameter enum test (double) (optional) + */ + public class TestEnumParametersOper { + + public static final String REQ_URI = "/fake"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestEnumParametersOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("*/*"); + reqSpec.setAccept("*/*"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestEnumParametersOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("*/*"); + reqSpec.setAccept("*/*"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /fake + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * @param enumHeaderStringArray (List) Header parameter enum test (string array) (optional) + */ + public TestEnumParametersOper enumHeaderStringArrayHeader(String enumHeaderStringArray) { + reqSpec.addHeader("enum_header_string_array", enumHeaderStringArray); + return this; + } + + /** + * @param enumHeaderString (String) Header parameter enum test (string) (optional, default to -efg) + */ + public TestEnumParametersOper enumHeaderStringHeader(String enumHeaderString) { + reqSpec.addHeader("enum_header_string", enumHeaderString); + return this; + } + + /** + * @param enumQueryStringArray (List) Query parameter enum test (string array) (optional) + */ + public TestEnumParametersOper enumQueryStringArrayQuery(Object... enumQueryStringArray) { + reqSpec.addQueryParam("enum_query_string_array", enumQueryStringArray); + return this; + } + + /** + * @param enumQueryString (String) Query parameter enum test (string) (optional, default to -efg) + */ + public TestEnumParametersOper enumQueryStringQuery(Object... enumQueryString) { + reqSpec.addQueryParam("enum_query_string", enumQueryString); + return this; + } + + /** + * @param enumQueryInteger (Integer) Query parameter enum test (double) (optional) + */ + public TestEnumParametersOper enumQueryIntegerQuery(Object... enumQueryInteger) { + reqSpec.addQueryParam("enum_query_integer", enumQueryInteger); + return this; + } + + /** + * @param enumFormStringArray (List) Form parameter enum test (string array) (optional) + */ + public TestEnumParametersOper enumFormStringArrayForm(Object... enumFormStringArray) { + reqSpec.addFormParam("enum_form_string_array", enumFormStringArray); + return this; + } + + /** + * @param enumFormString (String) Form parameter enum test (string) (optional, default to -efg) + */ + public TestEnumParametersOper enumFormStringForm(Object... enumFormString) { + reqSpec.addFormParam("enum_form_string", enumFormString); + return this; + } + + /** + * @param enumQueryDouble (Double) Query parameter enum test (double) (optional) + */ + public TestEnumParametersOper enumQueryDoubleForm(Object... enumQueryDouble) { + reqSpec.addFormParam("enum_query_double", enumQueryDouble); + return this; + } + + /** + * Customise request specification + */ + public TestEnumParametersOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestEnumParametersOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * test inline additionalProperties + * + * + * @see #body request body (required) + */ + public class TestInlineAdditionalPropertiesOper { + + public static final String REQ_URI = "/fake/inline-additionalProperties"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestInlineAdditionalPropertiesOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestInlineAdditionalPropertiesOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /fake/inline-additionalProperties + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param param (Object) request body (required) + */ + public TestInlineAdditionalPropertiesOper body(Object param) { + reqSpec.setBody(getJSON().serialize(param)); + return this; + } + + /** + * Customise request specification + */ + public TestInlineAdditionalPropertiesOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestInlineAdditionalPropertiesOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * test json serialization of form data + * + * + * @see #paramForm field1 (required) + * @see #param2Form field2 (required) + */ + public class TestJsonFormDataOper { + + public static final String REQ_URI = "/fake/jsonFormData"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestJsonFormDataOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestJsonFormDataOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /fake/jsonFormData + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * @param param (String) field1 (required) + */ + public TestJsonFormDataOper paramForm(Object... param) { + reqSpec.addFormParam("param", param); + return this; + } + + /** + * @param param2 (String) field2 (required) + */ + public TestJsonFormDataOper param2Form(Object... param2) { + reqSpec.addFormParam("param2", param2); + return this; + } + + /** + * Customise request specification + */ + public TestJsonFormDataOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestJsonFormDataOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java new file mode 100644 index 000000000000..77a47d95b821 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -0,0 +1,146 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import com.google.gson.reflect.TypeToken; +import io.swagger.client.model.Client; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import io.swagger.client.JSON; + +import static io.restassured.http.Method.*; + +public class FakeClassnameTags123Api { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private FakeClassnameTags123Api(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static FakeClassnameTags123Api fakeClassnameTags123(RequestSpecBuilder reqSpec) { + return new FakeClassnameTags123Api(reqSpec); + } + + + public TestClassnameOper testClassname() { + return new TestClassnameOper(reqSpec); + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return FakeClassnameTags123Api + */ + public FakeClassnameTags123Api setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * To test class name in snake case + * + * + * @see #body client model (required) + * return Client + */ + public class TestClassnameOper { + + public static final String REQ_URI = "/fake_classname_test"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public TestClassnameOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public TestClassnameOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * PATCH /fake_classname_test + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(PATCH, REQ_URI)); + } + + /** + * PATCH /fake_classname_test + * @return Client + */ + public Client executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (Client) client model (required) + */ + public TestClassnameOper body(Client body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public TestClassnameOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public TestClassnameOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/PetApi.java new file mode 100644 index 000000000000..f04cb48af378 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/PetApi.java @@ -0,0 +1,661 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import com.google.gson.reflect.TypeToken; +import java.io.File; +import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.Pet; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import io.swagger.client.JSON; + +import static io.restassured.http.Method.*; + +public class PetApi { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private PetApi(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static PetApi pet(RequestSpecBuilder reqSpec) { + return new PetApi(reqSpec); + } + + + public AddPetOper addPet() { + return new AddPetOper(reqSpec); + } + + public DeletePetOper deletePet() { + return new DeletePetOper(reqSpec); + } + + public FindPetsByStatusOper findPetsByStatus() { + return new FindPetsByStatusOper(reqSpec); + } + + @Deprecated + public FindPetsByTagsOper findPetsByTags() { + return new FindPetsByTagsOper(reqSpec); + } + + public GetPetByIdOper getPetById() { + return new GetPetByIdOper(reqSpec); + } + + public UpdatePetOper updatePet() { + return new UpdatePetOper(reqSpec); + } + + public UpdatePetWithFormOper updatePetWithForm() { + return new UpdatePetWithFormOper(reqSpec); + } + + public UploadFileOper uploadFile() { + return new UploadFileOper(reqSpec); + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return PetApi + */ + public PetApi setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * Add a new pet to the store + * + * + * @see #body Pet object that needs to be added to the store (required) + */ + public class AddPetOper { + + public static final String REQ_URI = "/pet"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public AddPetOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public AddPetOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /pet + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param body (Pet) Pet object that needs to be added to the store (required) + */ + public AddPetOper body(Pet body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public AddPetOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public AddPetOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Deletes a pet + * + * + * @see #petIdPath Pet id to delete (required) + * @see #apiKeyHeader (optional) + */ + public class DeletePetOper { + + public static final String REQ_URI = "/pet/{petId}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public DeletePetOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public DeletePetOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * DELETE /pet/{petId} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(DELETE, REQ_URI)); + } + + /** + * @param apiKey (String) (optional) + */ + public DeletePetOper apiKeyHeader(String apiKey) { + reqSpec.addHeader("api_key", apiKey); + return this; + } + + /** + * @param petId (Long) Pet id to delete (required) + */ + public DeletePetOper petIdPath(Object petId) { + reqSpec.addPathParam("petId", petId); + return this; + } + + /** + * Customise request specification + */ + public DeletePetOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public DeletePetOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * + * @see #statusQuery Status values that need to be considered for filter (required) + * return List + */ + public class FindPetsByStatusOper { + + public static final String REQ_URI = "/pet/findByStatus"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public FindPetsByStatusOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public FindPetsByStatusOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /pet/findByStatus + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /pet/findByStatus + * @return List + */ + public List executeAs(Function handler) { + Type type = new TypeToken>(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param status (List) Status values that need to be considered for filter (required) + */ + public FindPetsByStatusOper statusQuery(Object... status) { + reqSpec.addQueryParam("status", status); + return this; + } + + /** + * Customise request specification + */ + public FindPetsByStatusOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public FindPetsByStatusOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @see #tagsQuery Tags to filter by (required) + * return List + * @deprecated + */ + @Deprecated + public class FindPetsByTagsOper { + + public static final String REQ_URI = "/pet/findByTags"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public FindPetsByTagsOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public FindPetsByTagsOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /pet/findByTags + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /pet/findByTags + * @return List + */ + public List executeAs(Function handler) { + Type type = new TypeToken>(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param tags (List) Tags to filter by (required) + */ + public FindPetsByTagsOper tagsQuery(Object... tags) { + reqSpec.addQueryParam("tags", tags); + return this; + } + + /** + * Customise request specification + */ + public FindPetsByTagsOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public FindPetsByTagsOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Find pet by ID + * Returns a single pet + * + * @see #petIdPath ID of pet to return (required) + * return Pet + */ + public class GetPetByIdOper { + + public static final String REQ_URI = "/pet/{petId}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public GetPetByIdOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public GetPetByIdOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /pet/{petId} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /pet/{petId} + * @return Pet + */ + public Pet executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param petId (Long) ID of pet to return (required) + */ + public GetPetByIdOper petIdPath(Object petId) { + reqSpec.addPathParam("petId", petId); + return this; + } + + /** + * Customise request specification + */ + public GetPetByIdOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public GetPetByIdOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Update an existing pet + * + * + * @see #body Pet object that needs to be added to the store (required) + */ + public class UpdatePetOper { + + public static final String REQ_URI = "/pet"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public UpdatePetOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public UpdatePetOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * PUT /pet + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(PUT, REQ_URI)); + } + + /** + * @param body (Pet) Pet object that needs to be added to the store (required) + */ + public UpdatePetOper body(Pet body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public UpdatePetOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public UpdatePetOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Updates a pet in the store with form data + * + * + * @see #petIdPath ID of pet that needs to be updated (required) + * @see #nameForm Updated name of the pet (optional) + * @see #statusForm Updated status of the pet (optional) + */ + public class UpdatePetWithFormOper { + + public static final String REQ_URI = "/pet/{petId}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public UpdatePetWithFormOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/x-www-form-urlencoded"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public UpdatePetWithFormOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/x-www-form-urlencoded"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /pet/{petId} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param petId (Long) ID of pet that needs to be updated (required) + */ + public UpdatePetWithFormOper petIdPath(Object petId) { + reqSpec.addPathParam("petId", petId); + return this; + } + + /** + * @param name (String) Updated name of the pet (optional) + */ + public UpdatePetWithFormOper nameForm(Object... name) { + reqSpec.addFormParam("name", name); + return this; + } + + /** + * @param status (String) Updated status of the pet (optional) + */ + public UpdatePetWithFormOper statusForm(Object... status) { + reqSpec.addFormParam("status", status); + return this; + } + + /** + * Customise request specification + */ + public UpdatePetWithFormOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public UpdatePetWithFormOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * uploads an image + * + * + * @see #petIdPath ID of pet to update (required) + * @see #additionalMetadataForm Additional data to pass to server (optional) + * @see #fileMultiPart file to upload (optional) + * return ModelApiResponse + */ + public class UploadFileOper { + + public static final String REQ_URI = "/pet/{petId}/uploadImage"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public UploadFileOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("multipart/form-data"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public UploadFileOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("multipart/form-data"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /pet/{petId}/uploadImage + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /pet/{petId}/uploadImage + * @return ModelApiResponse + */ + public ModelApiResponse executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param petId (Long) ID of pet to update (required) + */ + public UploadFileOper petIdPath(Object petId) { + reqSpec.addPathParam("petId", petId); + return this; + } + + /** + * @param additionalMetadata (String) Additional data to pass to server (optional) + */ + public UploadFileOper additionalMetadataForm(Object... additionalMetadata) { + reqSpec.addFormParam("additionalMetadata", additionalMetadata); + return this; + } + + /** + * It will assume that the control name is file and the is + * @see #reqSpec for customise + * @param file(File) file to upload (optional) + */ + public UploadFileOper fileMultiPart(File file) { + reqSpec.addMultiPart(file); + return this; + } + + /** + * Customise request specification + */ + public UploadFileOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public UploadFileOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/StoreApi.java new file mode 100644 index 000000000000..6542851c376a --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/StoreApi.java @@ -0,0 +1,340 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import com.google.gson.reflect.TypeToken; +import io.swagger.client.model.Order; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import io.swagger.client.JSON; + +import static io.restassured.http.Method.*; + +public class StoreApi { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private StoreApi(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static StoreApi store(RequestSpecBuilder reqSpec) { + return new StoreApi(reqSpec); + } + + + public DeleteOrderOper deleteOrder() { + return new DeleteOrderOper(reqSpec); + } + + public GetInventoryOper getInventory() { + return new GetInventoryOper(reqSpec); + } + + public GetOrderByIdOper getOrderById() { + return new GetOrderByIdOper(reqSpec); + } + + public PlaceOrderOper placeOrder() { + return new PlaceOrderOper(reqSpec); + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return StoreApi + */ + public StoreApi setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @see #orderIdPath ID of the order that needs to be deleted (required) + */ + public class DeleteOrderOper { + + public static final String REQ_URI = "/store/order/{order_id}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public DeleteOrderOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public DeleteOrderOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * DELETE /store/order/{order_id} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(DELETE, REQ_URI)); + } + + /** + * @param orderId (String) ID of the order that needs to be deleted (required) + */ + public DeleteOrderOper orderIdPath(Object orderId) { + reqSpec.addPathParam("order_id", orderId); + return this; + } + + /** + * Customise request specification + */ + public DeleteOrderOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public DeleteOrderOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * + * return Map + */ + public class GetInventoryOper { + + public static final String REQ_URI = "/store/inventory"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public GetInventoryOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public GetInventoryOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /store/inventory + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /store/inventory + * @return Map + */ + public Map executeAs(Function handler) { + Type type = new TypeToken>(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * Customise request specification + */ + public GetInventoryOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public GetInventoryOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @see #orderIdPath ID of pet that needs to be fetched (required) + * return Order + */ + public class GetOrderByIdOper { + + public static final String REQ_URI = "/store/order/{order_id}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public GetOrderByIdOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public GetOrderByIdOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /store/order/{order_id} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /store/order/{order_id} + * @return Order + */ + public Order executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param orderId (Long) ID of pet that needs to be fetched (required) + */ + public GetOrderByIdOper orderIdPath(Object orderId) { + reqSpec.addPathParam("order_id", orderId); + return this; + } + + /** + * Customise request specification + */ + public GetOrderByIdOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public GetOrderByIdOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Place an order for a pet + * + * + * @see #body order placed for purchasing the pet (required) + * return Order + */ + public class PlaceOrderOper { + + public static final String REQ_URI = "/store/order"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public PlaceOrderOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public PlaceOrderOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /store/order + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * POST /store/order + * @return Order + */ + public Order executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param body (Order) order placed for purchasing the pet (required) + */ + public PlaceOrderOper body(Order body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public PlaceOrderOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public PlaceOrderOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/UserApi.java new file mode 100644 index 000000000000..342d58b4cb91 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/api/UserApi.java @@ -0,0 +1,598 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import com.google.gson.reflect.TypeToken; +import io.swagger.client.model.User; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.response.Response; + +import java.lang.reflect.Type; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import io.swagger.client.JSON; + +import static io.restassured.http.Method.*; + +public class UserApi { + + private RequestSpecBuilder reqSpec; + + private JSON json; + + private UserApi(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + this.json = new JSON(); + } + + public static UserApi user(RequestSpecBuilder reqSpec) { + return new UserApi(reqSpec); + } + + + public CreateUserOper createUser() { + return new CreateUserOper(reqSpec); + } + + public CreateUsersWithArrayInputOper createUsersWithArrayInput() { + return new CreateUsersWithArrayInputOper(reqSpec); + } + + public CreateUsersWithListInputOper createUsersWithListInput() { + return new CreateUsersWithListInputOper(reqSpec); + } + + public DeleteUserOper deleteUser() { + return new DeleteUserOper(reqSpec); + } + + public GetUserByNameOper getUserByName() { + return new GetUserByNameOper(reqSpec); + } + + public LoginUserOper loginUser() { + return new LoginUserOper(reqSpec); + } + + public LogoutUserOper logoutUser() { + return new LogoutUserOper(reqSpec); + } + + public UpdateUserOper updateUser() { + return new UpdateUserOper(reqSpec); + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return UserApi + */ + public UserApi setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * Create user + * This can only be done by the logged in user. + * + * @see #body Created user object (required) + */ + public class CreateUserOper { + + public static final String REQ_URI = "/user"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public CreateUserOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public CreateUserOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /user + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param body (User) Created user object (required) + */ + public CreateUserOper body(User body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public CreateUserOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public CreateUserOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Creates list of users with given input array + * + * + * @see #body List of user object (required) + */ + public class CreateUsersWithArrayInputOper { + + public static final String REQ_URI = "/user/createWithArray"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public CreateUsersWithArrayInputOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public CreateUsersWithArrayInputOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /user/createWithArray + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param body (List) List of user object (required) + */ + public CreateUsersWithArrayInputOper body(List body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public CreateUsersWithArrayInputOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public CreateUsersWithArrayInputOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Creates list of users with given input array + * + * + * @see #body List of user object (required) + */ + public class CreateUsersWithListInputOper { + + public static final String REQ_URI = "/user/createWithList"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public CreateUsersWithListInputOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public CreateUsersWithListInputOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * POST /user/createWithList + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(POST, REQ_URI)); + } + + /** + * @param body (List) List of user object (required) + */ + public CreateUsersWithListInputOper body(List body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * Customise request specification + */ + public CreateUsersWithListInputOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public CreateUsersWithListInputOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Delete user + * This can only be done by the logged in user. + * + * @see #usernamePath The name that needs to be deleted (required) + */ + public class DeleteUserOper { + + public static final String REQ_URI = "/user/{username}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public DeleteUserOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public DeleteUserOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * DELETE /user/{username} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(DELETE, REQ_URI)); + } + + /** + * @param username (String) The name that needs to be deleted (required) + */ + public DeleteUserOper usernamePath(Object username) { + reqSpec.addPathParam("username", username); + return this; + } + + /** + * Customise request specification + */ + public DeleteUserOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public DeleteUserOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Get user by user name + * + * + * @see #usernamePath The name that needs to be fetched. Use user1 for testing. (required) + * return User + */ + public class GetUserByNameOper { + + public static final String REQ_URI = "/user/{username}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public GetUserByNameOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public GetUserByNameOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /user/{username} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /user/{username} + * @return User + */ + public User executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param username (String) The name that needs to be fetched. Use user1 for testing. (required) + */ + public GetUserByNameOper usernamePath(Object username) { + reqSpec.addPathParam("username", username); + return this; + } + + /** + * Customise request specification + */ + public GetUserByNameOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public GetUserByNameOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Logs user into the system + * + * + * @see #usernameQuery The user name for login (required) + * @see #passwordQuery The password for login in clear text (required) + * return String + */ + public class LoginUserOper { + + public static final String REQ_URI = "/user/login"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public LoginUserOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public LoginUserOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /user/login + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * GET /user/login + * @return String + */ + public String executeAs(Function handler) { + Type type = new TypeToken(){}.getType(); + return getJSON().deserialize(execute(handler).asString(), type); + } + + /** + * @param username (String) The user name for login (required) + */ + public LoginUserOper usernameQuery(Object... username) { + reqSpec.addQueryParam("username", username); + return this; + } + + /** + * @param password (String) The password for login in clear text (required) + */ + public LoginUserOper passwordQuery(Object... password) { + reqSpec.addQueryParam("password", password); + return this; + } + + /** + * Customise request specification + */ + public LoginUserOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public LoginUserOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Logs out current logged in user session + * + * + */ + public class LogoutUserOper { + + public static final String REQ_URI = "/user/logout"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public LogoutUserOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public LogoutUserOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * GET /user/logout + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(GET, REQ_URI)); + } + + /** + * Customise request specification + */ + public LogoutUserOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public LogoutUserOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } + /** + * Updated user + * This can only be done by the logged in user. + * + * @see #usernamePath name that need to be deleted (required) + * @see #body Updated user object (required) + */ + public class UpdateUserOper { + + public static final String REQ_URI = "/user/{username}"; + + private RequestSpecBuilder reqSpec; + + private ResponseSpecBuilder respSpec; + + public UpdateUserOper() { + this.reqSpec = new RequestSpecBuilder(); + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + public UpdateUserOper(RequestSpecBuilder reqSpec) { + this.reqSpec = reqSpec; + reqSpec.setContentType("application/json"); + reqSpec.setAccept("application/json"); + this.respSpec = new ResponseSpecBuilder(); + } + + /** + * PUT /user/{username} + */ + public T execute(Function handler) { + return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(PUT, REQ_URI)); + } + + /** + * @param body (User) Updated user object (required) + */ + public UpdateUserOper body(User body) { + reqSpec.setBody(getJSON().serialize(body)); + return this; + } + + /** + * @param username (String) name that need to be deleted (required) + */ + public UpdateUserOper usernamePath(Object username) { + reqSpec.addPathParam("username", username); + return this; + } + + /** + * Customise request specification + */ + public UpdateUserOper reqSpec(Consumer consumer) { + consumer.accept(reqSpec); + return this; + } + + /** + * Customise response specification + */ + public UpdateUserOper respSpec(Consumer consumer) { + consumer.accept(respSpec); + return this; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..a1d984bdcf16 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java @@ -0,0 +1,136 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * AdditionalPropertiesClass + */ + +public class AdditionalPropertiesClass { + @SerializedName("map_property") + private Map mapProperty = null; + + @SerializedName("map_of_map_property") + private Map> mapOfMapProperty = null; + + public AdditionalPropertiesClass mapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + return this; + } + + public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) { + if (this.mapProperty == null) { + this.mapProperty = new HashMap(); + } + this.mapProperty.put(key, mapPropertyItem); + return this; + } + + /** + * Get mapProperty + * @return mapProperty + **/ + @ApiModelProperty(value = "") + public Map getMapProperty() { + return mapProperty; + } + + public void setMapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + } + + public AdditionalPropertiesClass mapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + return this; + } + + public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map mapOfMapPropertyItem) { + if (this.mapOfMapProperty == null) { + this.mapOfMapProperty = new HashMap>(); + } + this.mapOfMapProperty.put(key, mapOfMapPropertyItem); + return this; + } + + /** + * Get mapOfMapProperty + * @return mapOfMapProperty + **/ + @ApiModelProperty(value = "") + public Map> getMapOfMapProperty() { + return mapOfMapProperty; + } + + public void setMapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapProperty, additionalPropertiesClass.mapProperty) && + Objects.equals(this.mapOfMapProperty, additionalPropertiesClass.mapOfMapProperty); + } + + @Override + public int hashCode() { + return Objects.hash(mapProperty, mapOfMapProperty); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapProperty: ").append(toIndentedString(mapProperty)).append("\n"); + sb.append(" mapOfMapProperty: ").append(toIndentedString(mapOfMapProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Animal.java new file mode 100644 index 000000000000..fbbaef5c1e42 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Animal.java @@ -0,0 +1,121 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Animal + */ + + +public class Animal { + @SerializedName("className") + private String className = null; + + @SerializedName("color") + private String color = "red"; + + public Animal() { + this.className = this.getClass().getSimpleName(); + } + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + **/ + @ApiModelProperty(required = true, value = "") + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + **/ + @ApiModelProperty(value = "") + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 000000000000..a470f42e1256 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,66 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + +/** + * AnimalFarm + */ + +public class AnimalFarm extends ArrayList { + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..fdcfdba65227 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,105 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * ArrayOfArrayOfNumberOnly + */ + +public class ArrayOfArrayOfNumberOnly { + @SerializedName("ArrayArrayNumber") + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + **/ + @ApiModelProperty(value = "") + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..26b4422e7b2d --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java @@ -0,0 +1,105 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * ArrayOfNumberOnly + */ + +public class ArrayOfNumberOnly { + @SerializedName("ArrayNumber") + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + **/ + @ApiModelProperty(value = "") + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayTest.java new file mode 100644 index 000000000000..df413692f8bf --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ArrayTest.java @@ -0,0 +1,167 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.ReadOnlyFirst; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * ArrayTest + */ + +public class ArrayTest { + @SerializedName("array_of_string") + private List arrayOfString = null; + + @SerializedName("array_array_of_integer") + private List> arrayArrayOfInteger = null; + + @SerializedName("array_array_of_model") + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + **/ + @ApiModelProperty(value = "") + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + **/ + @ApiModelProperty(value = "") + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + **/ + @ApiModelProperty(value = "") + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Capitalization.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Capitalization.java new file mode 100644 index 000000000000..6a66eca36b02 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Capitalization.java @@ -0,0 +1,209 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Capitalization + */ + +public class Capitalization { + @SerializedName("smallCamel") + private String smallCamel = null; + + @SerializedName("CapitalCamel") + private String capitalCamel = null; + + @SerializedName("small_Snake") + private String smallSnake = null; + + @SerializedName("Capital_Snake") + private String capitalSnake = null; + + @SerializedName("SCA_ETH_Flow_Points") + private String scAETHFlowPoints = null; + + @SerializedName("ATT_NAME") + private String ATT_NAME = null; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + **/ + @ApiModelProperty(value = "") + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + **/ + @ApiModelProperty(value = "") + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + **/ + @ApiModelProperty(value = "") + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + **/ + @ApiModelProperty(value = "") + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + **/ + @ApiModelProperty(value = "") + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + **/ + @ApiModelProperty(value = "Name of the pet ") + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_NAME)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Cat.java new file mode 100644 index 000000000000..4019e804b4f5 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Cat.java @@ -0,0 +1,96 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Animal; +import java.io.IOException; + +/** + * Cat + */ + +public class Cat extends Animal { + @SerializedName("declawed") + private Boolean declawed = null; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + **/ + @ApiModelProperty(value = "") + public Boolean isDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Category.java new file mode 100644 index 000000000000..6534aa559a23 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Category.java @@ -0,0 +1,117 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Category + */ + +public class Category { + @SerializedName("id") + private Long id = null; + + @SerializedName("name") + private String name = null; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ClassModel.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ClassModel.java new file mode 100644 index 000000000000..a3c5c882bbde --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ClassModel.java @@ -0,0 +1,95 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Model for testing model with \"_class\" property + */ +@ApiModel(description = "Model for testing model with \"_class\" property") + +public class ClassModel { + @SerializedName("_class") + private String propertyClass = null; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Client.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Client.java new file mode 100644 index 000000000000..e3b95f7e0661 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Client.java @@ -0,0 +1,94 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Client + */ + +public class Client { + @SerializedName("client") + private String client = null; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + **/ + @ApiModelProperty(value = "") + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Dog.java new file mode 100644 index 000000000000..b810784f0427 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Dog.java @@ -0,0 +1,96 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Animal; +import java.io.IOException; + +/** + * Dog + */ + +public class Dog extends Animal { + @SerializedName("breed") + private String breed = null; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + **/ + @ApiModelProperty(value = "") + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumArrays.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumArrays.java new file mode 100644 index 000000000000..6e69be28d66d --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumArrays.java @@ -0,0 +1,221 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * EnumArrays + */ + +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + @JsonAdapter(JustSymbolEnum.Adapter.class) + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static JustSymbolEnum fromValue(String text) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final JustSymbolEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public JustSymbolEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return JustSymbolEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("just_symbol") + private JustSymbolEnum justSymbol = null; + + /** + * Gets or Sets arrayEnum + */ + @JsonAdapter(ArrayEnumEnum.Adapter.class) + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ArrayEnumEnum fromValue(String text) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ArrayEnumEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ArrayEnumEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ArrayEnumEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("array_enum") + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + **/ + @ApiModelProperty(value = "") + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + **/ + @ApiModelProperty(value = "") + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumClass.java new file mode 100644 index 000000000000..f219a419f662 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumClass.java @@ -0,0 +1,75 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets EnumClass + */ +@JsonAdapter(EnumClass.Adapter.class) +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EnumClass fromValue(String text) { + for (EnumClass b : EnumClass.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EnumClass enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EnumClass read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EnumClass.fromValue(String.valueOf(value)); + } + } +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumTest.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumTest.java new file mode 100644 index 000000000000..a572c0d6b5bb --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/EnumTest.java @@ -0,0 +1,307 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.OuterEnum; +import java.io.IOException; + +/** + * EnumTest + */ + +public class EnumTest { + /** + * Gets or Sets enumString + */ + @JsonAdapter(EnumStringEnum.Adapter.class) + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EnumStringEnum fromValue(String text) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EnumStringEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EnumStringEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EnumStringEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("enum_string") + private EnumStringEnum enumString = null; + + /** + * Gets or Sets enumInteger + */ + @JsonAdapter(EnumIntegerEnum.Adapter.class) + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EnumIntegerEnum fromValue(String text) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EnumIntegerEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { + Integer value = jsonReader.nextInt(); + return EnumIntegerEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("enum_integer") + private EnumIntegerEnum enumInteger = null; + + /** + * Gets or Sets enumNumber + */ + @JsonAdapter(EnumNumberEnum.Adapter.class) + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EnumNumberEnum fromValue(String text) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EnumNumberEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EnumNumberEnum read(final JsonReader jsonReader) throws IOException { + Double value = jsonReader.nextDouble(); + return EnumNumberEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("enum_number") + private EnumNumberEnum enumNumber = null; + + @SerializedName("outerEnum") + private OuterEnum outerEnum = null; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + **/ + @ApiModelProperty(value = "") + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + **/ + @ApiModelProperty(value = "") + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + **/ + @ApiModelProperty(value = "") + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + **/ + @ApiModelProperty(value = "") + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumInteger, enumNumber, outerEnum); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/FormatTest.java new file mode 100644 index 000000000000..3223d7667532 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/FormatTest.java @@ -0,0 +1,384 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.UUID; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; + +/** + * FormatTest + */ + +public class FormatTest { + @SerializedName("integer") + private Integer integer = null; + + @SerializedName("int32") + private Integer int32 = null; + + @SerializedName("int64") + private Long int64 = null; + + @SerializedName("number") + private BigDecimal number = null; + + @SerializedName("float") + private Float _float = null; + + @SerializedName("double") + private Double _double = null; + + @SerializedName("string") + private String string = null; + + @SerializedName("byte") + private byte[] _byte = null; + + @SerializedName("binary") + private byte[] binary = null; + + @SerializedName("date") + private LocalDate date = null; + + @SerializedName("dateTime") + private OffsetDateTime dateTime = null; + + @SerializedName("uuid") + private UUID uuid = null; + + @SerializedName("password") + private String password = null; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + **/ + @ApiModelProperty(value = "") + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + **/ + @ApiModelProperty(value = "") + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + **/ + @ApiModelProperty(value = "") + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + **/ + @ApiModelProperty(required = true, value = "") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + **/ + @ApiModelProperty(value = "") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + **/ + @ApiModelProperty(value = "") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + **/ + @ApiModelProperty(value = "") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + **/ + @ApiModelProperty(required = true, value = "") + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(byte[] binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + **/ + @ApiModelProperty(value = "") + public byte[] getBinary() { + return binary; + } + + public void setBinary(byte[] binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + **/ + @ApiModelProperty(required = true, value = "") + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + **/ + @ApiModelProperty(value = "") + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @ApiModelProperty(value = "") + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(required = true, value = "") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Arrays.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), Arrays.hashCode(binary), date, dateTime, uuid, password); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..389d6955fb40 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java @@ -0,0 +1,99 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * HasOnlyReadOnly + */ + +public class HasOnlyReadOnly { + @SerializedName("bar") + private String bar = null; + + @SerializedName("foo") + private String foo = null; + + /** + * Get bar + * @return bar + **/ + @ApiModelProperty(value = "") + public String getBar() { + return bar; + } + + /** + * Get foo + * @return foo + **/ + @ApiModelProperty(value = "") + public String getFoo() { + return foo; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/MapTest.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/MapTest.java new file mode 100644 index 000000000000..26cf37c65d8d --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/MapTest.java @@ -0,0 +1,183 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * MapTest + */ + +public class MapTest { + @SerializedName("map_map_of_string") + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + @JsonAdapter(InnerEnum.Adapter.class) + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static InnerEnum fromValue(String text) { + for (InnerEnum b : InnerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final InnerEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public InnerEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return InnerEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("map_of_enum_string") + private Map mapOfEnumString = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + **/ + @ApiModelProperty(value = "") + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + **/ + @ApiModelProperty(value = "") + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..435dc7ec0ee4 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,154 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Animal; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.threeten.bp.OffsetDateTime; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ + +public class MixedPropertiesAndAdditionalPropertiesClass { + @SerializedName("uuid") + private UUID uuid = null; + + @SerializedName("dateTime") + private OffsetDateTime dateTime = null; + + @SerializedName("map") + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @ApiModelProperty(value = "") + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + **/ + @ApiModelProperty(value = "") + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + **/ + @ApiModelProperty(value = "") + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Model200Response.java new file mode 100644 index 000000000000..1bcc6ac44bfd --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Model200Response.java @@ -0,0 +1,118 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Model for testing model name starting with number + */ +@ApiModel(description = "Model for testing model name starting with number") + +public class Model200Response { + @SerializedName("name") + private Integer name = null; + + @SerializedName("class") + private String propertyClass = null; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200Response = (Model200Response) o; + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.propertyClass, _200Response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 000000000000..faed84888dc6 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,140 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * ModelApiResponse + */ + +public class ModelApiResponse { + @SerializedName("code") + private Integer code = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("message") + private String message = null; + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ModelReturn.java new file mode 100644 index 000000000000..f64c0e8f0b81 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ModelReturn.java @@ -0,0 +1,95 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Model for testing reserved words + */ +@ApiModel(description = "Model for testing reserved words") + +public class ModelReturn { + @SerializedName("return") + private Integer _return = null; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + **/ + @ApiModelProperty(value = "") + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Name.java new file mode 100644 index 000000000000..f6a3f8f41955 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Name.java @@ -0,0 +1,146 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Model for testing model name same as property name + */ +@ApiModel(description = "Model for testing model name same as property name") + +public class Name { + @SerializedName("name") + private Integer name = null; + + @SerializedName("snake_case") + private Integer snakeCase = null; + + @SerializedName("property") + private String property = null; + + @SerializedName("123Number") + private Integer _123Number = null; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(required = true, value = "") + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + /** + * Get snakeCase + * @return snakeCase + **/ + @ApiModelProperty(value = "") + public Integer getSnakeCase() { + return snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + /** + * Get _123Number + * @return _123Number + **/ + @ApiModelProperty(value = "") + public Integer get123Number() { + return _123Number; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123Number, name._123Number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123Number); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/NumberOnly.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/NumberOnly.java new file mode 100644 index 000000000000..8f1010ad4fa2 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/NumberOnly.java @@ -0,0 +1,95 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; + +/** + * NumberOnly + */ + +public class NumberOnly { + @SerializedName("JustNumber") + private BigDecimal justNumber = null; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + **/ + @ApiModelProperty(value = "") + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Order.java new file mode 100644 index 000000000000..b121d4cf4afa --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Order.java @@ -0,0 +1,259 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.threeten.bp.OffsetDateTime; + +/** + * Order + */ + +public class Order { + @SerializedName("id") + private Long id = null; + + @SerializedName("petId") + private Long petId = null; + + @SerializedName("quantity") + private Integer quantity = null; + + @SerializedName("shipDate") + private OffsetDateTime shipDate = null; + + /** + * Order Status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("status") + private StatusEnum status = null; + + @SerializedName("complete") + private Boolean complete = false; + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + **/ + @ApiModelProperty(value = "") + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + **/ + @ApiModelProperty(value = "") + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order shipDate(OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + **/ + @ApiModelProperty(value = "") + public OffsetDateTime getShipDate() { + return shipDate; + } + + public void setShipDate(OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + **/ + @ApiModelProperty(value = "Order Status") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + **/ + @ApiModelProperty(value = "") + public Boolean isComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/OuterComposite.java new file mode 100644 index 000000000000..a1fb77fbca04 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/OuterComposite.java @@ -0,0 +1,141 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; + +/** + * OuterComposite + */ + +public class OuterComposite { + @SerializedName("my_number") + private BigDecimal myNumber = null; + + @SerializedName("my_string") + private String myString = null; + + @SerializedName("my_boolean") + private Boolean myBoolean = null; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + **/ + @ApiModelProperty(value = "") + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + **/ + @ApiModelProperty(value = "") + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + **/ + @ApiModelProperty(value = "") + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/OuterEnum.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/OuterEnum.java new file mode 100644 index 000000000000..6bc039c16680 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/OuterEnum.java @@ -0,0 +1,75 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets OuterEnum + */ +@JsonAdapter(OuterEnum.Adapter.class) +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OuterEnum fromValue(String text) { + for (OuterEnum b : OuterEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OuterEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public OuterEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return OuterEnum.fromValue(String.valueOf(value)); + } + } +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Pet.java new file mode 100644 index 000000000000..22c29a1bedeb --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Pet.java @@ -0,0 +1,275 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Category; +import io.swagger.client.model.Tag; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Pet + */ + +public class Pet { + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Category category = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + @SerializedName("tags") + private List tags = null; + + /** + * pet status in the store + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("status") + private StatusEnum status = null; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + @ApiModelProperty(value = "") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "doggie", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + @ApiModelProperty(required = true, value = "") + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..c8517f81bc17 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/ReadOnlyFirst.java @@ -0,0 +1,108 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * ReadOnlyFirst + */ + +public class ReadOnlyFirst { + @SerializedName("bar") + private String bar = null; + + @SerializedName("baz") + private String baz = null; + + /** + * Get bar + * @return bar + **/ + @ApiModelProperty(value = "") + public String getBar() { + return bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + **/ + @ApiModelProperty(value = "") + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/SpecialModelName.java new file mode 100644 index 000000000000..9c0a4477a04a --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -0,0 +1,94 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * SpecialModelName + */ + +public class SpecialModelName { + @SerializedName("$special[property.name]") + private Long specialPropertyName = null; + + public SpecialModelName specialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + return this; + } + + /** + * Get specialPropertyName + * @return specialPropertyName + **/ + @ApiModelProperty(value = "") + public Long getSpecialPropertyName() { + return specialPropertyName; + } + + public void setSpecialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName specialModelName = (SpecialModelName) o; + return Objects.equals(this.specialPropertyName, specialModelName.specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash(specialPropertyName); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Tag.java new file mode 100644 index 000000000000..a36d1300236d --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/Tag.java @@ -0,0 +1,117 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Tag + */ + +public class Tag { + @SerializedName("id") + private Long id = null; + + @SerializedName("name") + private String name = null; + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/User.java new file mode 100644 index 000000000000..25bc8d9ba40b --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/io/swagger/client/model/User.java @@ -0,0 +1,255 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * User + */ + +public class User { + @SerializedName("id") + private Long id = null; + + @SerializedName("username") + private String username = null; + + @SerializedName("firstName") + private String firstName = null; + + @SerializedName("lastName") + private String lastName = null; + + @SerializedName("email") + private String email = null; + + @SerializedName("password") + private String password = null; + + @SerializedName("phone") + private String phone = null; + + @SerializedName("userStatus") + private Integer userStatus = null; + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @ApiModelProperty(value = "") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @ApiModelProperty(value = "") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @ApiModelProperty(value = "") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @ApiModelProperty(value = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(value = "") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + **/ + @ApiModelProperty(value = "") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + **/ + @ApiModelProperty(value = "User Status") + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/AnotherFakeApiTest.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/AnotherFakeApiTest.java new file mode 100644 index 000000000000..edfaf2c42864 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/AnotherFakeApiTest.java @@ -0,0 +1,55 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import io.swagger.client.ApiClient; +import io.swagger.client.model.Client; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.restassured.config.RestAssuredConfig.config; +import static io.swagger.client.GsonObjectMapper.gson; + +/** + * API tests for AnotherFakeApi + */ +@Ignore +public class AnotherFakeApiTest { + + private AnotherFakeApi api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("http://petstore.swagger.io:80/v2"))).anotherFake(); + } + + /** + * successful operation + */ + @Test + public void shouldSee200AfterTestSpecialTags() { + Client body = null; + api.testSpecialTags() + .body(body).execute(r -> r.prettyPeek()); + // TODO: test validations + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/FakeApiTest.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/FakeApiTest.java new file mode 100644 index 000000000000..cc77c0e9b912 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/FakeApiTest.java @@ -0,0 +1,221 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import io.swagger.client.ApiClient; +import io.swagger.client.model.Client; +import io.swagger.client.model.OuterComposite; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; + +import java.math.BigDecimal; +import java.util.List; + +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.restassured.config.RestAssuredConfig.config; +import static io.swagger.client.GsonObjectMapper.gson; + +/** + * API tests for FakeApi + */ +@Ignore +public class FakeApiTest { + + private FakeApi api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); + } + + /** + * Output boolean + */ + @Test + public void shouldSee200AfterFakeOuterBooleanSerialize() { + Boolean body = null; + api.fakeOuterBooleanSerialize().execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * Output composite + */ + @Test + public void shouldSee200AfterFakeOuterCompositeSerialize() { + OuterComposite body = null; + api.fakeOuterCompositeSerialize().execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * Output number + */ + @Test + public void shouldSee200AfterFakeOuterNumberSerialize() { + BigDecimal body = null; + api.fakeOuterNumberSerialize().execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * Output string + */ + @Test + public void shouldSee200AfterFakeOuterStringSerialize() { + String body = null; + api.fakeOuterStringSerialize().execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * successful operation + */ + @Test + public void shouldSee200AfterTestClientModel() { + Client body = null; + api.testClientModel() + .body(body).execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * Invalid username supplied + */ + @Test + public void shouldSee400AfterTestEndpointParameters() { + BigDecimal number = null; + Double _double = null; + String patternWithoutDelimiter = null; + byte[] _byte = null; + Integer integer = null; + Integer int32 = null; + Long int64 = null; + Float _float = null; + String string = null; + byte[] binary = null; + LocalDate date = null; + OffsetDateTime dateTime = null; + String password = null; + String paramCallback = null; + api.testEndpointParameters() + .numberForm(number) + ._doubleForm(_double) + .patternWithoutDelimiterForm(patternWithoutDelimiter) + ._byteForm(_byte).execute(r -> r.prettyPeek()); + // TODO: test validations + } + + /** + * User not found + */ + @Test + public void shouldSee404AfterTestEndpointParameters() { + BigDecimal number = null; + Double _double = null; + String patternWithoutDelimiter = null; + byte[] _byte = null; + Integer integer = null; + Integer int32 = null; + Long int64 = null; + Float _float = null; + String string = null; + byte[] binary = null; + LocalDate date = null; + OffsetDateTime dateTime = null; + String password = null; + String paramCallback = null; + api.testEndpointParameters() + .numberForm(number) + ._doubleForm(_double) + .patternWithoutDelimiterForm(patternWithoutDelimiter) + ._byteForm(_byte).execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * Invalid request + */ + @Test + public void shouldSee400AfterTestEnumParameters() { + List enumFormStringArray = null; + String enumFormString = null; + String enumHeaderStringArray = null; + String enumHeaderString = null; + List enumQueryStringArray = null; + String enumQueryString = null; + Integer enumQueryInteger = null; + Double enumQueryDouble = null; + api.testEnumParameters().execute(r -> r.prettyPeek()); + // TODO: test validations + } + + /** + * Not found + */ + @Test + public void shouldSee404AfterTestEnumParameters() { + List enumFormStringArray = null; + String enumFormString = null; + String enumHeaderStringArray = null; + String enumHeaderString = null; + List enumQueryStringArray = null; + String enumQueryString = null; + Integer enumQueryInteger = null; + Double enumQueryDouble = null; + api.testEnumParameters().execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * successful operation + */ + @Test + public void shouldSee200AfterTestInlineAdditionalProperties() { + Object param = null; + api.testInlineAdditionalProperties() + .body(param).execute(r -> r.prettyPeek()); + // TODO: test validations + } + + + /** + * successful operation + */ + @Test + public void shouldSee200AfterTestJsonFormData() { + String param = null; + String param2 = null; + api.testJsonFormData() + .paramForm(param) + .param2Form(param2).execute(r -> r.prettyPeek()); + // TODO: test validations + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java new file mode 100644 index 000000000000..21f82221826f --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java @@ -0,0 +1,55 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import io.swagger.client.ApiClient; +import io.swagger.client.model.Client; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.restassured.config.RestAssuredConfig.config; +import static io.swagger.client.GsonObjectMapper.gson; + +/** + * API tests for FakeClassnameTags123Api + */ +@Ignore +public class FakeClassnameTags123ApiTest { + + private FakeClassnameTags123Api api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("http://petstore.swagger.io:80/v2"))).fakeClassnameTags123(); + } + + /** + * successful operation + */ + @Test + public void shouldSee200AfterTestClassname() { + Client body = null; + api.testClassname() + .body(body).execute(r -> r.prettyPeek()); + // TODO: test validations + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/PetApiTest.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/PetApiTest.java new file mode 100644 index 000000000000..3ba3a116092e --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/PetApiTest.java @@ -0,0 +1,122 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import io.swagger.client.ApiClient; +import io.swagger.client.model.Category; +import io.swagger.client.model.Pet; +import org.junit.Before; +import org.junit.Test; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static io.restassured.RestAssured.config; +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.swagger.client.GsonObjectMapper.gson; +import static io.swagger.client.ResponseSpecBuilders.shouldBeCode; +import static io.swagger.client.ResponseSpecBuilders.validatedWith; +import static io.swagger.client.model.Pet.StatusEnum.AVAILABLE; +import static io.swagger.client.model.Pet.StatusEnum.PENDING; +import static io.swagger.client.model.Pet.StatusEnum.SOLD; +import static org.apache.http.HttpStatus.SC_NOT_FOUND; +import static org.apache.http.HttpStatus.SC_OK; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * API tests for PetApi + */ +public class PetApiTest { + + private PetApi api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("http://petstore.swagger.io:80/v2"))).pet(); + } + + @Test + public void statusListTest() { + Pet pet = getPet(); + api.addPet().body(pet.status(PENDING)).execute(validatedWith(shouldBeCode(SC_OK))); + List statusList = Arrays.asList(PENDING.getValue()); + List petsId = api.findPetsByStatus() + .statusQuery(statusList.toArray()).executeAs(validatedWith(shouldBeCode(SC_OK))) + .stream().map(Pet::getId).collect(Collectors.toList()); + assertThat(petsId, hasItem(pet.getId())); + api.deletePet().petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void getPetByIdTest() { + Pet pet = getPet(); + api.addPet().body(pet.status(PENDING)).execute(validatedWith(shouldBeCode(SC_OK))); + Pet fetchedPet = api.getPetById() + .petIdPath(pet.getId()).executeAs(validatedWith(shouldBeCode(SC_OK))); + assertThat(fetchedPet.getId(), equalTo(pet.getId())); + api.deletePet().petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void deletePet() { + Pet pet = getPet(); + api.addPet().body(pet.status(PENDING)).execute(validatedWith(shouldBeCode(SC_OK))); + api.deletePet().petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_OK))); + api.getPetById() + .petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_NOT_FOUND))); + } + + @Test + public void uploadFileTest() throws IOException { + Pet pet = getPet(); + api.addPet().body(pet).execute(validatedWith(shouldBeCode(SC_OK))); + File file = new File("hello.txt"); + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write("Hello world!"); + writer.close(); + api.uploadFile().fileMultiPart(file) + .petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_OK))); + api.deletePet().petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void updatePetTest() { + Pet pet = getPet(); + api.addPet().body(pet).execute(validatedWith(shouldBeCode(SC_OK))); + api.updatePet().body(pet.status(SOLD)).execute(validatedWith(shouldBeCode(SC_OK))); + Pet.StatusEnum statusEnum = api.getPetById().petIdPath(pet.getId()).executeAs(validatedWith(shouldBeCode(SC_OK))).getStatus(); + assertThat(statusEnum, equalTo(SOLD)); + api.deletePet().petIdPath(pet.getId()).execute(validatedWith(shouldBeCode(SC_OK))); + } + + + private Pet getPet() { + return new Pet().id(TestUtils.nextId()).name("alex").status(AVAILABLE) + .category(new Category().id(TestUtils.nextId()).name("dog")) + .photoUrls(Arrays.asList("http://foo.bar.com/1")); + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/StoreApiTest.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/StoreApiTest.java new file mode 100644 index 000000000000..033a6a4fc8c3 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/StoreApiTest.java @@ -0,0 +1,84 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import io.swagger.client.ApiClient; +import io.swagger.client.model.Order; +import org.junit.Before; +import org.junit.Test; +import org.threeten.bp.OffsetDateTime; + +import java.util.Map; + +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.restassured.config.RestAssuredConfig.config; +import static io.swagger.client.GsonObjectMapper.gson; +import static io.swagger.client.ResponseSpecBuilders.shouldBeCode; +import static io.swagger.client.ResponseSpecBuilders.validatedWith; +import static org.apache.http.HttpStatus.SC_NOT_FOUND; +import static org.apache.http.HttpStatus.SC_OK; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; + +/** + * API tests for StoreApi + */ +public class StoreApiTest { + + private StoreApi api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("http://petstore.swagger.io:80/v2"))).store(); + } + + @Test + public void getInventoryTest() { + Map inventory = api.getInventory().executeAs(validatedWith(shouldBeCode(SC_OK))); + assertThat(inventory.keySet().size(), greaterThan(0)); + } + + @Test + public void getOrderByIdTest() { + Order order = getOrder(); + api.placeOrder().body(order).execute(validatedWith(shouldBeCode(SC_OK))); + Long orderId = api.getOrderById() + .orderIdPath(order.getId()).executeAs(validatedWith(shouldBeCode(SC_OK))).getId(); + assertThat(orderId, equalTo(order.getId())); + api.deleteOrder().orderIdPath(orderId).execute(validatedWith(shouldBeCode(SC_OK))); + + } + + @Test + public void placeAndDeleteOrderTest() { + Order order = getOrder(); + Long id = api.placeOrder() + .body(order).executeAs(validatedWith(shouldBeCode(SC_OK))).getId(); + api.deleteOrder().orderIdPath(id) + .execute(validatedWith(shouldBeCode(SC_OK))); + api.getOrderById().orderIdPath(order.getId()).execute(validatedWith(shouldBeCode(SC_NOT_FOUND))); + } + + private Order getOrder() { + return new Order().id(TestUtils.nextId()).complete(false).petId(0L) + .quantity(111).status(Order.StatusEnum.DELIVERED).shipDate(OffsetDateTime.now().withNano(123000000)); + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/TestUtils.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/TestUtils.java new file mode 100644 index 000000000000..776dd8aa63f1 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/TestUtils.java @@ -0,0 +1,18 @@ +package io.swagger.client.api; + +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +public class TestUtils { + private static final AtomicLong atomicId = createAtomicId(); + + public static long nextId() { + return atomicId.getAndIncrement(); + } + + private static AtomicLong createAtomicId() { + int baseId = new Random(System.currentTimeMillis()).nextInt(1000000) + 20000; + return new AtomicLong((long) baseId); + } +} + diff --git a/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/UserApiTest.java b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/UserApiTest.java new file mode 100644 index 000000000000..61b7775ef001 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/io/swagger/client/api/UserApiTest.java @@ -0,0 +1,132 @@ +/* + * Swagger 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 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.filter.log.ErrorLoggingFilter; +import io.swagger.client.ApiClient; +import io.swagger.client.model.User; +import org.junit.Before; +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; + +import static io.restassured.config.ObjectMapperConfig.objectMapperConfig; +import static io.restassured.config.RestAssuredConfig.config; +import static io.swagger.client.GsonObjectMapper.gson; +import static io.swagger.client.ResponseSpecBuilders.shouldBeCode; +import static io.swagger.client.ResponseSpecBuilders.validatedWith; +import static io.swagger.client.api.TestUtils.nextId; +import static org.apache.http.HttpStatus.SC_OK; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; + +/** + * API tests for UserApi + */ +public class UserApiTest { + + private UserApi api; + + @Before + public void createApi() { + api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( + () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) + .addFilter(new ErrorLoggingFilter()) + .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); + } + + @Test + public void createUsersWithArrayInputTest() { + User first = getUser().id(nextId()); + User second = getUser().id(nextId()); + List body = Arrays.asList(first, second); + api.createUsersWithArrayInput() + .body(body).execute(validatedWith(shouldBeCode(SC_OK))); + api.deleteUser().usernamePath(first.getUsername()).execute( + validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void createUsersWithListInputTest() { + User first = getUser().id(nextId()); + User second = getUser().id(nextId()); + List body = Arrays.asList(first, second); + api.createUsersWithListInput() + .body(body).execute(validatedWith(shouldBeCode(SC_OK))); + api.deleteUser().usernamePath(first.getUsername()).execute( + validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void createUserTest() { + String userName = "Blah"; + User user = getUser().username(userName); + api.createUser().body(user).execute(validatedWith(shouldBeCode(SC_OK))); + User fetched = api.getUserByName() + .usernamePath(userName).executeAs(validatedWith(shouldBeCode(SC_OK))); + + assertThat(fetched, notNullValue()); + assertThat(fetched.getUsername(), equalTo(userName)); + assertThat(fetched.getPassword(), equalTo(user.getPassword())); + assertThat(fetched.getEmail(), equalTo(user.getEmail())); + assertThat(fetched.getFirstName(), equalTo(user.getFirstName())); + assertThat(fetched.getLastName(), equalTo(user.getLastName())); + assertThat(fetched.getId(), equalTo(user.getId())); + api.deleteUser().usernamePath(user.getUsername()).execute( + validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void loginTest() { + String username = "a"; + String password = "b"; + String result = api.loginUser() + .usernameQuery(username) + .passwordQuery(password).executeAs(validatedWith(shouldBeCode(SC_OK))); + assertThat(result, containsString("logged in user session")); + + } + + @Test + public void logoutTest() { + api.logoutUser().execute(validatedWith(shouldBeCode(SC_OK))); + } + + @Test + public void updateUserTest() { + String username = "me"; + String email = "me@blah.com"; + User user = new User().username(username).email(email); + api.createUser().body(user).execute(validatedWith(shouldBeCode(SC_OK))); + api.updateUser() + .usernamePath(username) + .body(user).execute(validatedWith(shouldBeCode(SC_OK))); + User fetched = api.getUserByName().usernamePath(username).executeAs(validatedWith(shouldBeCode(SC_OK))); + assertThat(fetched, notNullValue()); + assertThat(fetched.getUsername(), equalTo(username)); + assertThat(fetched.getEmail(), equalTo(email)); + api.deleteUser().usernamePath(user.getUsername()).execute( + validatedWith(shouldBeCode(SC_OK))); + + } + + private User getUser() { + return new User().id(nextId()).username("Username") + .email("blah@blah.com").firstName("Firstname").lastName("Lastname").userStatus(1); + } +} \ No newline at end of file