diff --git a/bin/configs/java-okhttp-gson-nextgen.yaml b/bin/configs/java-okhttp-gson-nextgen.yaml index b6b12f86bddc..724edc9d9083 100644 --- a/bin/configs/java-okhttp-gson-nextgen.yaml +++ b/bin/configs/java-okhttp-gson-nextgen.yaml @@ -1,8 +1,7 @@ generatorName: java outputDir: samples/client/petstore/java/okhttp-gson-nextgen library: okhttp-gson-nextgen -#inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml templateDir: modules/openapi-generator/src/main/resources/Java additionalProperties: artifactId: petstore-okhttp-gson-nextgen diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/JSON.mustache index 56477b8dc179..32bef199e1cb 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/JSON.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/JSON.mustache @@ -50,19 +50,19 @@ import java.util.HashMap; * backward-compatibility */ public class JSON { - private Gson gson; - private boolean isLenientOnJson = false; - private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); - private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); {{#joda}} - private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter(); - private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); {{/joda}} {{#jsr310}} - private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); - private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); {{/jsr310}} - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); @SuppressWarnings("unchecked") public static GsonBuilder createGson() { @@ -116,7 +116,7 @@ public class JSON { return clazz; } - public JSON() { + { gson = createGson() .registerTypeAdapter(Date.class, dateTypeAdapter) .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) @@ -146,7 +146,7 @@ public class JSON { * * @return Gson */ - public Gson getGson() { + public static Gson getGson() { return gson; } @@ -155,11 +155,11 @@ public class JSON { * * @param gson Gson */ - public void setGson(Gson gson) { - this.gson = gson; + public static void setGson(Gson gson) { + JSON.gson = gson; } - public void setLenientOnJson(boolean lenientOnJson) { + public static void setLenientOnJson(boolean lenientOnJson) { isLenientOnJson = lenientOnJson; } @@ -169,7 +169,7 @@ public class JSON { * @param obj Object * @return String representation of the JSON */ - public String serialize(Object obj) { + public static String serialize(Object obj) { return gson.toJson(obj); } @@ -182,7 +182,7 @@ public class JSON { * @return The deserialized Java object */ @SuppressWarnings("unchecked") - public T deserialize(String body, Type returnType) { + public static T deserialize(String body, Type returnType) { try { if (isLenientOnJson) { JsonReader jsonReader = new JsonReader(new StringReader(body)); @@ -206,7 +206,7 @@ public class JSON { /** * Gson TypeAdapter for Byte Array type */ - public class ByteArrayAdapter extends TypeAdapter { + public static class ByteArrayAdapter extends TypeAdapter { @Override public void write(JsonWriter out, byte[] value) throws IOException { @@ -235,7 +235,7 @@ public class JSON { /** * Gson TypeAdapter for Joda DateTime type */ - public class DateTimeTypeAdapter extends TypeAdapter { + public static class DateTimeTypeAdapter extends TypeAdapter { private DateTimeFormatter formatter; @@ -278,7 +278,7 @@ public class JSON { /** * Gson TypeAdapter for Joda LocalDate type */ - public class LocalDateTypeAdapter extends TypeAdapter { + public static class LocalDateTypeAdapter extends TypeAdapter { private DateTimeFormatter formatter; @@ -316,11 +316,11 @@ public class JSON { } } - public void setDateTimeFormat(DateTimeFormatter dateFormat) { + public static void setDateTimeFormat(DateTimeFormatter dateFormat) { dateTimeTypeAdapter.setFormat(dateFormat); } - public void setLocalDateFormat(DateTimeFormatter dateFormat) { + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { localDateTypeAdapter.setFormat(dateFormat); } @@ -329,7 +329,7 @@ public class JSON { /** * Gson TypeAdapter for JSR310 OffsetDateTime type */ - public class OffsetDateTimeTypeAdapter extends TypeAdapter { + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { private DateTimeFormatter formatter; @@ -373,7 +373,7 @@ public class JSON { /** * Gson TypeAdapter for JSR310 LocalDate type */ - public class LocalDateTypeAdapter extends TypeAdapter { + public static class LocalDateTypeAdapter extends TypeAdapter { private DateTimeFormatter formatter; @@ -411,11 +411,11 @@ public class JSON { } } - public void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { offsetDateTimeTypeAdapter.setFormat(dateFormat); } - public void setLocalDateFormat(DateTimeFormatter dateFormat) { + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { localDateTypeAdapter.setFormat(dateFormat); } @@ -425,7 +425,7 @@ public class JSON { * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used * (more efficient than SimpleDateFormat). */ - public class SqlDateTypeAdapter extends TypeAdapter { + public static class SqlDateTypeAdapter extends TypeAdapter { private DateFormat dateFormat; @@ -478,7 +478,7 @@ public class JSON { * Gson TypeAdapter for java.util.Date type * If the dateFormat is null, ISO8601Utils will be used. */ - public class DateTypeAdapter extends TypeAdapter { + public static class DateTypeAdapter extends TypeAdapter { private DateFormat dateFormat; @@ -531,11 +531,11 @@ public class JSON { } } - public void setDateFormat(DateFormat dateFormat) { + public static void setDateFormat(DateFormat dateFormat) { dateTypeAdapter.setFormat(dateFormat); } - public void setSqlDateFormat(DateFormat dateFormat) { + public static void setSqlDateFormat(DateFormat dateFormat) { sqlDateTypeAdapter.setFormat(dateFormat); } } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/anyof_model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/anyof_model.mustache index 2b41e44940ae..fae56fd2923e 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/anyof_model.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/anyof_model.mustache @@ -90,14 +90,14 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im {{/discriminator}} {{/useOneOfDiscriminatorLookup}} - {{#anyOf}} // deserialize {{{.}}} try { - deserialized = adapter{{.}}.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + {{.}}.validateJsonObject(jsonObject); log.log(Level.FINER, "Input data matches schema '{{{.}}}'"); {{classname}} ret = new {{classname}}(); - ret.setActualInstance(deserialized); + ret.setActualInstance(adapter{{.}}.fromJsonTree(jsonObject)); return ret; } catch (Exception e) { // deserialization failed, continue @@ -105,7 +105,8 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im } {{/anyOf}} - throw new IOException(String.format("Failed deserialization for {{classname}} as data doesn't match anyOf schmeas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. JSON: %s", jsonObject.toString())); + + throw new IOException(String.format("Failed deserialization for {{classname}}: no class matched. JSON: %s", jsonObject.toString())); } }.nullSafe(); } @@ -188,4 +189,48 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im } {{/anyOf}} + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to {{classname}} + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + {{#anyOf}} + // validate the json string with {{{.}}} + try { + {{{.}}}.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + {{/anyOf}} + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for {{classname}} with anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of {{classname}} given an JSON string + * + * @param jsonString JSON string + * @return An instance of {{classname}} + * @throws IOException if the JSON string is invalid with respect to {{classname}} + */ + public static {{{classname}}} fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, {{{classname}}}.class); + } + + /** + * Convert an instance of {{classname}} to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/oneof_model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/oneof_model.mustache index a9300854dead..ce88e9a78ad8 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/oneof_model.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/oneof_model.mustache @@ -91,11 +91,14 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im {{/discriminator}} {{/useOneOfDiscriminatorLookup}} int match = 0; + TypeAdapter actualAdapter = elementAdapter; {{#oneOf}} // deserialize {{{.}}} try { - deserialized = adapter{{.}}.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + {{.}}.validateJsonObject(jsonObject); + actualAdapter = adapter{{.}}; match++; log.log(Level.FINER, "Input data matches schema '{{{.}}}'"); } catch (Exception e) { @@ -106,7 +109,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im {{/oneOf}} if (match == 1) { {{classname}} ret = new {{classname}}(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -193,4 +196,47 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im } {{/oneOf}} + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to {{classname}} + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + {{#oneOf}} + // validate the json string with {{{.}}} + try { + {{{.}}}.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + {{/oneOf}} + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for {{classname}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of {{classname}} given an JSON string + * + * @param jsonString JSON string + * @return An instance of {{classname}} + * @throws IOException if the JSON string is invalid with respect to {{classname}} + */ + public static {{{classname}}} fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, {{{classname}}}.class); + } + + /** + * Convert an instance of {{classname}} to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pojo.mustache index f7ad1e3a05a8..b30ce069f095 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pojo.mustache @@ -1,5 +1,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -14,6 +15,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import {{invokerPackage}}.JSON; + /** * {{description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}} * @deprecated{{/isDeprecated}} @@ -379,7 +382,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens } }; {{/parcelableModel}} -{{^hasChildren}} + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -397,6 +400,95 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{/requiredVars}} } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to {{classname}} + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if ({{classname}}.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in {{{classname}}} is not found in the empty JSON string", {{classname}}.openapiRequiredFields.toString())); + } + } + {{^hasChildren}} + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!{{classname}}.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + {{#requiredVars}} + {{#-first}} + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : {{classname}}.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + {{/-first}} + {{/requiredVars}} + {{/hasChildren}} + {{^discriminator}} + {{#vars}} + {{#isArray}} + {{#items.isModel}} + JsonArray jsonArray{{name}} = jsonObj.getAsJsonArray("{{{baseName}}}"); + {{#isRequired}} + // validate the required field `{{{baseName}}}` (array) + for (int i = 0; i < jsonArray{{name}}.size(); i++) { + {{{items.dataType}}}.validateJsonObject(jsonArray{{name}}.get(i).getAsJsonObject()); + }; + {{/isRequired}} + {{^isRequired}} + // validate the optional field `{{{baseName}}}` (array) + if (jsonArray{{name}} != null) { + for (int i = 0; i < jsonArray{{name}}.size(); i++) { + {{{items.dataType}}}.validateJsonObject(jsonArray{{name}}.get(i).getAsJsonObject()); + }; + } + {{/isRequired}} + {{/items.isModel}} + {{/isArray}} + {{^isContainer}} + {{#isModel}} + {{#isRequired}} + // validate the required field `{{{baseName}}}` + {{{dataType}}}.validateJsonObject(jsonObj.getAsJsonObject("{{{baseName}}}")); + {{/isRequired}} + {{^isRequired}} + // validate the optional field `{{{baseName}}}` + if (jsonObj.getAsJsonObject("{{{baseName}}}") != null) { + {{{dataType}}}.validateJsonObject(jsonObj.getAsJsonObject("{{{baseName}}}")); + } + {{/isRequired}} + {{/isModel}} + {{/isContainer}} + {{/vars}} + {{/discriminator}} + {{#hasChildren}} + {{#discriminator}} + + String discriminatorValue = jsonObj.get("{{{propertyBaseName}}}").getAsString(); + switch (discriminatorValue) { + {{#mappedModels}} + case "{{mappingName}}": + {{modelName}}.validateJsonObject(jsonObj); + break; + {{/mappedModels}} + default: + throw new IllegalArgumentException(String.format("The value of the `{{{propertyBaseName}}}` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue)); + } + {{/discriminator}} + {{/hasChildren}} + } + +{{^hasChildren}} public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -417,31 +509,33 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @Override public {{classname}} read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!{{classname}}.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `{{classname}}` properties"); - } - } - - {{#requiredVars}} - {{#-first}} - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : {{classname}}.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - {{/-first}} - {{/requiredVars}} - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } {{/hasChildren}} -} \ No newline at end of file + + /** + * Create an instance of {{classname}} given an JSON string + * + * @param jsonString JSON string + * @return An instance of {{classname}} + * @throws IOException if the JSON string is invalid with respect to {{classname}} + */ + public static {{{classname}}} fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, {{{classname}}}.class); + } + + /** + * Convert an instance of {{classname}} to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index 8ba2950c2d3e..a1d9b8ce8586 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -542,8 +542,8 @@ public void testMultipartCloud() throws IOException { // Check that the api handles the array and the file final File multipartApi = files.get("MultipartApi.java"); assertFileContains(multipartApi.toPath(), - "List files", - "MultipartFile file"); + "List files", + "MultipartFile file"); } @Test diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml new file mode 100644 index 000000000000..2ea7d82e8c0b --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml @@ -0,0 +1,2184 @@ +openapi: 3.0.0 +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '405': + description: Invalid input + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + deprecated: true + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generated exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + responses: + '400': + description: Invalid request + '404': + description: Not found + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + enum_form_string: + description: Form parameter enum test (string) + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + integer: + description: None + type: integer + minimum: 10 + maximum: 100 + int32: + description: None + type: integer + format: int32 + minimum: 20 + maximum: 200 + int64: + description: None + type: integer + format: int64 + number: + description: None + type: number + minimum: 32.1 + maximum: 543.2 + float: + description: None + type: number + format: float + maximum: 987.6 + double: + description: None + type: number + format: double + minimum: 67.8 + maximum: 123.4 + string: + description: None + type: string + pattern: '/[a-z]/i' + pattern_without_delimiter: + description: None + type: string + pattern: '^[A-Z].*' + byte: + description: None + type: string + format: byte + binary: + description: None + type: string + format: binary + date: + description: None + type: string + format: date + dateTime: + description: None + type: string + format: date-time + default: '2010-02-01T10:20:10.11111+01:00' + example: '2020-02-02T20:20:20.22222Z' + password: + description: None + type: string + format: password + minLength: 10 + maxLength: 64 + callback: + description: None + type: string + required: + - number + - double + - pattern_without_delimiter + - byte + delete: + tags: + - fake + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + x-group-parameters: true + parameters: + - name: required_string_group + in: query + description: Required String in group parameters + required: true + schema: + type: integer + - name: required_boolean_group + in: header + description: Required Boolean in group parameters + required: true + schema: + type: boolean + - name: required_int64_group + in: query + description: Required Integer in group parameters + required: true + schema: + type: integer + format: int64 + - name: string_group + in: query + description: String in group parameters + schema: + type: integer + - name: boolean_group + in: header + description: Boolean in group parameters + schema: + type: boolean + - name: int64_group + in: query + description: Integer in group parameters + schema: + type: integer + format: int64 + responses: + '400': + description: Someting wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + responses: + '200': + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + responses: + '200': + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + responses: + '200': + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + responses: + '200': + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + responses: + '200': + description: successful operation + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: string + description: request body + required: true + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags and operation ID starting with number + operationId: '123_test_@#$%_special_tags' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' +# /fake/body-with-file-schema: +# put: +# tags: +# - fake +# description: >- +# For this test, the body for this request much reference a schema named +# `File`. +# operationId: testBodyWithFileSchema +# responses: +# '200': +# description: Success +# requestBody: +# content: +# application/json: +# schema: +# $ref: '#/components/schemas/FileSchemaTestClass' +# required: true + /fake/test-query-parameters: + put: + tags: + - fake + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - name: pipe + in: query + required: true + schema: + type: array + items: + type: string + - name: ioutil + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: http + in: query + required: true + style: spaceDelimited + schema: + type: array + items: + type: string + - name: url + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: context + in: query + required: true + explode: true + schema: + type: array + items: + type: string + responses: + "200": + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + type: string + format: binary + required: + - requiredFile + /fake/health: + get: + tags: + - fake + summary: Health check endpoint + responses: + 200: + description: The instance started successfully + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' + /fake/array-of-enums: + get: + tags: + - fake + summary: Array of Enums + operationId: getArrayOfEnums + responses: + 200: + description: Got named array of enums + content: + application/json: + schema: + $ref: '#/components/schemas/ArrayOfEnums' +servers: + - url: 'http://{server}.swagger.io:{port}/v2' + description: petstore server + variables: + server: + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + - url: https://localhost:8080/{version} + description: The local server + variables: + version: + enum: + - 'v1' + - 'v2' + default: 'v2' + - url: https://127.0.0.1/no_variable + description: The local server without variables +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + examples: + simple-list: + summary: Simple list example + description: Should not get into code examples + value: + - username: foo + - username: bar + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + http_signature_test: + # Test the 'HTTP signature' security scheme. + # Each HTTP request is cryptographically signed as specified + # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ + type: http + scheme: signature + schemas: + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + example: '2020-02-02T20:20:20.000222Z' + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + objectWithNoDeclaredProps: + type: object + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + description: test code generation for objects + Value must be a map of strings to values. It cannot be the 'null' value. + objectWithNoDeclaredPropsNullable: + type: object + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + description: test code generation for nullable objects. + Value must be a map of strings to values or the 'null' value. + nullable: true + anyTypeProp: + description: test code generation for any type + Here the 'type' attribute is not specified, which means the value can be anything, + including the null value, string, number, boolean, array or object. + See https://github.com/OAI/OpenAPI-Specification/issues/1389 + # TODO: this should be supported, currently there are some issues in the code generation. + #anyTypeExceptNullProp: + # description: any type except 'null' + # Here the 'type' attribute is not specified, which means the value can be anything, + # including the null value, string, number, boolean, array or object. + # not: + # type: 'null' + anyTypePropNullable: + description: test code generation for any type + Here the 'type' attribute is not specified, which means the value can be anything, + including the null value, string, number, boolean, array or object. + The 'nullable' attribute does not change the allowed values. + nullable: true + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Return: + description: Model for testing reserved words + properties: + return: + type: integer + format: int32 + xml: + name: Return + Name: + description: Model for testing model name same as property name + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + readOnly: true + type: integer + format: int32 + property: + type: string + 123Number: + type: integer + readOnly: true + xml: + name: Name + 200_response: + description: Model for testing model name starting with number + properties: + name: + type: integer + format: int32 + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - type: object + properties: + declawed: + type: boolean + Address: + type: object + additionalProperties: + type: integer + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + type: object + required: + - number + - byte + - date + - password + properties: + integer: + type: integer + maximum: 100 + minimum: 10 + multipleOf: 2 + int32: + type: integer + format: int32 + maximum: 200 + minimum: 20 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + multipleOf: 32.5 + float: + type: number + format: float + maximum: 987.6 + minimum: 54.3 + double: + type: number + format: double + maximum: 123.4 + minimum: 67.8 + decimal: + type: string + format: number + string: + type: string + pattern: '/[a-z]/i' + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + example: '2020-02-02' + dateTime: + type: string + format: date-time + example: '2007-12-03T10:15:30+01:00' + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + password: + type: string + format: password + maxLength: 64 + minLength: 10 + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + type: string + pattern: '^\d{10}$' + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + type: string + pattern: '/^image_\d{1,3}$/i' + EnumClass: + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + Enum_Test: + type: object + required: + - enum_string_required + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - '' + enum_string_required: + type: string + enum: + - UPPER + - lower + - '' + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_integer_only: + type: integer + enum: + - 2 + - -2 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + anytype_1: {} + map_with_undeclared_properties_anytype_1: + type: object + map_with_undeclared_properties_anytype_2: + type: object + properties: {} + map_with_undeclared_properties_anytype_3: + type: object + additionalProperties: true + empty_map: + type: object + description: an object with no declared properties and no undeclared + properties, hence it's an empty map. + additionalProperties: false + map_with_undeclared_properties_string: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + NumberOnly: + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + OuterEnum: + nullable: true + type: string + enum: + - placed + - approved + - delivered + OuterEnumInteger: + type: integer + enum: + - 0 + - 1 + - 2 + OuterEnumDefaultValue: + type: string + enum: + - placed + - approved + - delivered + default: placed + OuterEnumIntegerDefaultValue: + type: integer + enum: + - 0 + - 1 + - 2 + default: 0 + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean +# FileSchemaTestClass: +# type: object +# properties: +# file: +# $ref: '#/components/schemas/File' +# files: +# type: array +# items: +# $ref: '#/components/schemas/File' + File: + type: object + description: Must be named `File` for test. + properties: + sourceURI: + description: Test capitalization + type: string + _special_model.name_: + properties: + '$special[property.name]': + type: integer + format: int64 + '_special_model.name_': + type: string + xml: + name: '$special[model.name]' + HealthCheckResult: + type: object + properties: + NullableMessage: + nullable: true + type: string + description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + NullableClass: + type: object + properties: + integer_prop: + type: integer + nullable: true + number_prop: + type: number + nullable: true + boolean_prop: + type: boolean + nullable: true + string_prop: + type: string + nullable: true + date_prop: + type: string + format: date + nullable: true + datetime_prop: + type: string + format: date-time + nullable: true + array_nullable_prop: + type: array + nullable: true + items: + type: object + array_and_items_nullable_prop: + type: array + nullable: true + items: + type: object + nullable: true + array_items_nullable: + type: array + items: + type: object + nullable: true + object_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + object_and_items_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + object_items_nullable: + type: object + additionalProperties: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + fruit: + properties: + color: + type: string + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + # Below additionalProperties is set to false to validate the use + # case when a composed schema has additionalProperties set to false. + additionalProperties: false + apple: + type: object + properties: + cultivar: + type: string + pattern: ^[a-zA-Z\s]*$ + origin: + type: string + pattern: /^[A-Z\s]*$/i + nullable: true + banana: + type: object + properties: + lengthCm: + type: number + mammal: + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + - $ref: '#/components/schemas/Pig' + discriminator: + propertyName: className + whale: + type: object + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + zebra: + type: object + properties: + type: + type: string + enum: + - plains + - mountain + - grevys + className: + type: string + required: + - className + additionalProperties: true + Pig: + oneOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + discriminator: + propertyName: className + BasquePig: + type: object + properties: + className: + type: string + required: + - className + DanishPig: + type: object + properties: + className: + type: string + required: + - className + gmFruit: + properties: + color: + type: string + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + additionalProperties: false + fruitReq: + oneOf: + - type: 'null' + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + additionalProperties: false + appleReq: + type: object + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + additionalProperties: false + bananaReq: + type: object + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + additionalProperties: false + # go-experimental is unable to make Triangle and Quadrilateral models + # correctly https://github.com/OpenAPITools/openapi-generator/issues/6149 + Drawing: + type: object + properties: + mainShape: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value cannot be null. + $ref: '#/components/schemas/Shape' + shapeOrNull: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value may be null because ShapeOrNull has 'null' + # type as a child schema of 'oneOf'. + $ref: '#/components/schemas/ShapeOrNull' + nullableShape: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value may be null because NullableShape has the + # 'nullable: true' attribute. For this specific scenario this is exactly the + # same thing as 'shapeOrNull'. + $ref: '#/components/schemas/NullableShape' + shapes: + type: array + items: + $ref: '#/components/schemas/Shape' + additionalProperties: + # Here the additional properties are specified using a referenced schema. + # This is just to validate the generated code works when using $ref + # under 'additionalProperties'. + $ref: '#/components/schemas/fruit' + Shape: + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + ShapeOrNull: + description: The value may be a shape or the 'null' value. + This is introduced in OAS schema >= 3.1. + oneOf: + - type: 'null' + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + NullableShape: + description: The value may be a shape or the 'null' value. + The 'nullable' attribute was introduced in OAS schema >= 3.0 + and has been deprecated in OAS schema >= 3.1. + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + nullable: true + ShapeInterface: + properties: + shapeType: + type: string + required: + - shapeType + TriangleInterface: + properties: + triangleType: + type: string + required: + - triangleType + Triangle: + oneOf: + - $ref: '#/components/schemas/EquilateralTriangle' + - $ref: '#/components/schemas/IsoscelesTriangle' + - $ref: '#/components/schemas/ScaleneTriangle' + discriminator: + propertyName: triangleType + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + EquilateralTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + IsoscelesTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + additionalProperties: false + ScaleneTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + QuadrilateralInterface: + properties: + quadrilateralType: + type: string + required: + - quadrilateralType + Quadrilateral: + oneOf: + - $ref: '#/components/schemas/SimpleQuadrilateral' + - $ref: '#/components/schemas/ComplexQuadrilateral' + discriminator: + propertyName: quadrilateralType + SimpleQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + ComplexQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + GrandparentAnimal: + type: object + required: + - pet_type + properties: + pet_type: + type: string + discriminator: + propertyName: pet_type + ParentPet: + type: object + allOf: + - $ref: '#/components/schemas/GrandparentAnimal' + #ChildCat: + # allOf: + # - $ref: '#/components/schemas/ParentPet' + # - type: object + # properties: + # name: + # type: string + # pet_type: + # x-enum-as-string: true + # type: string + # enum: + # - ChildCat + # default: ChildCat + ArrayOfEnums: + type: array + items: + $ref: '#/components/schemas/OuterEnum' + DateTimeTest: + type: string + default: '2010-01-01T10:10:10.000111+01:00' + example: '2010-01-01T10:10:10.000111+01:00' + format: date-time + DeprecatedObject: + type: object + deprecated: true + properties: + name: + type: string + ObjectWithDeprecatedFields: + type: object + properties: + uuid: + type: string + id: + type: number + deprecated: true + deprecatedRef: + $ref: '#/components/schemas/DeprecatedObject' + bars: + type: array + deprecated: true + items: + $ref: '#/components/schemas/Bar' + PetWithRequiredTags: + type: object + required: + - name + - photoUrls + - tags + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson.yaml index 92b32a47679d..3ae78d049cea 100644 --- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson.yaml @@ -2143,3 +2143,42 @@ components: deprecated: true items: $ref: '#/components/schemas/Bar' + PetWithRequiredTags: + type: object + required: + - name + - photoUrls + - tags + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet diff --git a/samples/client/petstore/java-micronaut-client/docs/ModelFile.md b/samples/client/petstore/java-micronaut-client/docs/ModelFile.md new file mode 100644 index 000000000000..014716aba6a3 --- /dev/null +++ b/samples/client/petstore/java-micronaut-client/docs/ModelFile.md @@ -0,0 +1,17 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | `String` | Test capitalization | [optional property] + + + + + + diff --git a/samples/client/petstore/java-micronaut-client/docs/ModelList.md b/samples/client/petstore/java-micronaut-client/docs/ModelList.md new file mode 100644 index 000000000000..6468645316ca --- /dev/null +++ b/samples/client/petstore/java-micronaut-client/docs/ModelList.md @@ -0,0 +1,16 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | `String` | | [optional property] + + + + + + diff --git a/samples/client/petstore/java-micronaut-client/src/main/java/org/openapitools/model/ModelFile.java b/samples/client/petstore/java-micronaut-client/src/main/java/org/openapitools/model/ModelFile.java new file mode 100644 index 000000000000..7112952184c0 --- /dev/null +++ b/samples/client/petstore/java-micronaut-client/src/main/java/org/openapitools/model/ModelFile.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.*; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import io.micronaut.core.annotation.*; +import javax.annotation.Generated; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@Generated(value="org.openapitools.codegen.languages.JavaMicronautClientCodegen") +@Introspected +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSourceURI() { + return sourceURI; + } + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/samples/client/petstore/java-micronaut-client/src/main/java/org/openapitools/model/ModelList.java b/samples/client/petstore/java-micronaut-client/src/main/java/org/openapitools/model/ModelList.java new file mode 100644 index 000000000000..9aa652a72ee4 --- /dev/null +++ b/samples/client/petstore/java-micronaut-client/src/main/java/org/openapitools/model/ModelList.java @@ -0,0 +1,99 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.*; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import io.micronaut.core.annotation.*; +import javax.annotation.Generated; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@Generated(value="org.openapitools.codegen.languages.JavaMicronautClientCodegen") +@Introspected +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String get123list() { + return _123list; + } + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/samples/client/petstore/java-micronaut-client/src/test/groovy/org/openapitools/model/ModelFileSpec.groovy b/samples/client/petstore/java-micronaut-client/src/test/groovy/org/openapitools/model/ModelFileSpec.groovy new file mode 100644 index 000000000000..437aa0a889bf --- /dev/null +++ b/samples/client/petstore/java-micronaut-client/src/test/groovy/org/openapitools/model/ModelFileSpec.groovy @@ -0,0 +1,30 @@ +package org.openapitools.model + +import io.swagger.annotations.ApiModel +import io.swagger.annotations.ApiModelProperty +import io.micronaut.test.extensions.spock.annotation.MicronautTest +import spock.lang.Specification +import jakarta.inject.Inject + +/** + * Model tests for ModelFile + */ +@MicronautTest +public class ModelFileSpec extends Specification { + private final ModelFile model = new ModelFile() + + /** + * Model tests for ModelFile + */ + void 'ModelFile test'() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + void 'ModelFile property sourceURI test'() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java-micronaut-client/src/test/groovy/org/openapitools/model/ModelListSpec.groovy b/samples/client/petstore/java-micronaut-client/src/test/groovy/org/openapitools/model/ModelListSpec.groovy new file mode 100644 index 000000000000..90939aa97617 --- /dev/null +++ b/samples/client/petstore/java-micronaut-client/src/test/groovy/org/openapitools/model/ModelListSpec.groovy @@ -0,0 +1,30 @@ +package org.openapitools.model + +import io.swagger.annotations.ApiModel +import io.swagger.annotations.ApiModelProperty +import io.micronaut.test.extensions.spock.annotation.MicronautTest +import spock.lang.Specification +import jakarta.inject.Inject + +/** + * Model tests for ModelList + */ +@MicronautTest +public class ModelListSpec extends Specification { + private final ModelList model = new ModelList() + + /** + * Model tests for ModelList + */ + void 'ModelList test'() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + void 'ModelList property _123list test'() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/docs/ModelFile.md b/samples/client/petstore/java/apache-httpclient/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/apache-httpclient/docs/ModelList.md b/samples/client/petstore/java/apache-httpclient/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..e441f435fba2 --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.concurrent.Immutable +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..ea6f66358227 --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.concurrent.Immutable +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/feign-no-nullable/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/feign-no-nullable/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..2617cb1bae47 --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for ModelFile + */ +class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/feign-no-nullable/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/feign-no-nullable/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..e2c3bb9a1016 --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for ModelList + */ +class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..2617cb1bae47 --- /dev/null +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for ModelFile + */ +class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..e2c3bb9a1016 --- /dev/null +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for ModelList + */ +class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/google-api-client/docs/ModelFile.md b/samples/client/petstore/java/google-api-client/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/google-api-client/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/google-api-client/docs/ModelList.md b/samples/client/petstore/java/google-api-client/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/google-api-client/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/google-api-client/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/google-api-client/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/google-api-client/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/google-api-client/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/google-api-client/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/google-api-client/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/jersey1/docs/ModelFile.md b/samples/client/petstore/java/jersey1/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/jersey1/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/jersey1/docs/ModelList.md b/samples/client/petstore/java/jersey1/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/jersey1/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/jersey1/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/jersey1/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/jersey1/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/jersey1/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/jersey1/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/jersey1/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/docs/ModelFile.md b/samples/client/petstore/java/jersey2-java8-localdatetime/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/docs/ModelList.md b/samples/client/petstore/java/jersey2-java8-localdatetime/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..0de39ec2ab0a --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,113 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + /** + * Return true if this File object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..19025e8ec4f3 --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,112 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + /** + * Return true if this List object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/jersey2-java8/docs/ModelFile.md b/samples/client/petstore/java/jersey2-java8/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/jersey2-java8/docs/ModelList.md b/samples/client/petstore/java/jersey2-java8/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..0de39ec2ab0a --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,113 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + /** + * Return true if this File object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..19025e8ec4f3 --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,112 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + /** + * Return true if this List object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/native-async/docs/ModelFile.md b/samples/client/petstore/java/native-async/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/native-async/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/native-async/docs/ModelList.md b/samples/client/petstore/java/native-async/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/native-async/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..2a6605d18c8e --- /dev/null +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,112 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + /** + * Return true if this File object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2db90d8dc136 --- /dev/null +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,111 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + /** + * Return true if this List object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/native-async/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/native-async/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/native-async/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/native-async/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/native-async/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/native-async/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/native/docs/ModelFile.md b/samples/client/petstore/java/native/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/native/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/native/docs/ModelList.md b/samples/client/petstore/java/native/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/native/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..2a6605d18c8e --- /dev/null +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,112 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + /** + * Return true if this File object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2db90d8dc136 --- /dev/null +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,111 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + /** + * Return true if this List object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/native/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/native/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/native/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/native/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/native/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/native/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/ModelFile.md b/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/ModelList.md b/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..111a748ceff8 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,101 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2ba46fefd4fe --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/FileSchemaTestClassTest.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ModelFileTest.java similarity index 63% rename from samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/FileSchemaTestClassTest.java rename to samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ModelFileTest.java index 0ca366212088..132012d4c387 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/FileSchemaTestClassTest.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -21,41 +21,31 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; /** - * Model tests for FileSchemaTestClass + * Model tests for ModelFile */ -public class FileSchemaTestClassTest { - private final FileSchemaTestClass model = new FileSchemaTestClass(); +public class ModelFileTest { + private final ModelFile model = new ModelFile(); /** - * Model tests for FileSchemaTestClass + * Model tests for ModelFile */ @Test - public void testFileSchemaTestClass() { - // TODO: test FileSchemaTestClass + public void testModelFile() { + // TODO: test ModelFile } /** - * Test the property 'file' + * Test the property 'sourceURI' */ @Test - public void fileTest() { - // TODO: test file - } - - /** - * Test the property 'files' - */ - @Test - public void filesTest() { - // TODO: test files + public void sourceURITest() { + // TODO: test sourceURI } } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/.openapi-generator/FILES b/samples/client/petstore/java/okhttp-gson-nextgen/.openapi-generator/FILES index 39148a7980a7..4b91a4644222 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/.openapi-generator/FILES +++ b/samples/client/petstore/java/okhttp-gson-nextgen/.openapi-generator/FILES @@ -34,7 +34,6 @@ docs/EnumTest.md docs/EquilateralTriangle.md docs/FakeApi.md docs/FakeClassnameTags123Api.md -docs/FileSchemaTestClass.md docs/Foo.md docs/FormatTest.md docs/Fruit.md @@ -65,6 +64,7 @@ docs/OuterEnumIntegerDefaultValue.md docs/ParentPet.md docs/Pet.md docs/PetApi.md +docs/PetWithRequiredTags.md docs/Pig.md docs/Quadrilateral.md docs/QuadrilateralInterface.md @@ -147,7 +147,6 @@ src/main/java/org/openapitools/client/model/EnumArrays.java src/main/java/org/openapitools/client/model/EnumClass.java src/main/java/org/openapitools/client/model/EnumTest.java src/main/java/org/openapitools/client/model/EquilateralTriangle.java -src/main/java/org/openapitools/client/model/FileSchemaTestClass.java src/main/java/org/openapitools/client/model/Foo.java src/main/java/org/openapitools/client/model/FormatTest.java src/main/java/org/openapitools/client/model/Fruit.java @@ -177,6 +176,7 @@ src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/ParentPet.java src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/PetWithRequiredTags.java src/main/java/org/openapitools/client/model/Pig.java src/main/java/org/openapitools/client/model/Quadrilateral.java src/main/java/org/openapitools/client/model/QuadrilateralInterface.java diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/README.md b/samples/client/petstore/java/okhttp-gson-nextgen/README.md index 6110aea0fa04..865b6ae5aa1d 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/README.md +++ b/samples/client/petstore/java/okhttp-gson-nextgen/README.md @@ -121,7 +121,6 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | *FakeApi* | [**getArrayOfEnums**](docs/FakeApi.md#getArrayOfEnums) | **GET** /fake/array-of-enums | Array of Enums -*FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -182,7 +181,6 @@ Class | Method | HTTP request | Description - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) - [EquilateralTriangle](docs/EquilateralTriangle.md) - - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [Foo](docs/Foo.md) - [FormatTest](docs/FormatTest.md) - [Fruit](docs/Fruit.md) @@ -212,6 +210,7 @@ Class | Method | HTTP request | Description - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [ParentPet](docs/ParentPet.md) - [Pet](docs/Pet.md) + - [PetWithRequiredTags](docs/PetWithRequiredTags.md) - [Pig](docs/Pig.md) - [Quadrilateral](docs/Quadrilateral.md) - [QuadrilateralInterface](docs/QuadrilateralInterface.md) diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson-nextgen/api/openapi.yaml index 8e64d05d5f2f..ecee30d7d093 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson-nextgen/api/openapi.yaml @@ -1107,24 +1107,6 @@ paths: - $another-fake? x-contentType: application/json x-accepts: application/json - /fake/body-with-file-schema: - put: - description: For this test, the body for this request much reference a schema - named `File`. - operationId: testBodyWithFileSchema - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/FileSchemaTestClass' - required: true - responses: - "200": - description: Success - tags: - - fake - x-contentType: application/json - x-accepts: application/json /fake/test-query-parameters: put: description: To test the collection format in query parameters @@ -1934,25 +1916,8 @@ components: additionalProperties: type: boolean type: object - FileSchemaTestClass: - example: - file: - sourceURI: sourceURI - files: - - sourceURI: sourceURI - - sourceURI: sourceURI - properties: - file: - $ref: '#/components/schemas/File' - files: - items: - $ref: '#/components/schemas/File' - type: array - type: object File: description: Must be named `File` for test. - example: - sourceURI: sourceURI properties: sourceURI: description: Test capitalization @@ -2279,6 +2244,45 @@ components: $ref: '#/components/schemas/Bar' type: array type: object + PetWithRequiredTags: + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + - tags + type: object + xml: + name: Pet inline_response_default: example: string: diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-nextgen/docs/FakeApi.md index bee53680247b..505117ba63fa 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson-nextgen/docs/FakeApi.md @@ -10,7 +10,6 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**getArrayOfEnums**](FakeApi.md#getArrayOfEnums) | **GET** /fake/array-of-enums | Array of Enums -[**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | [**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -357,63 +356,6 @@ No authorization required |-------------|-------------|------------------| **200** | Got named array of enums | - | - -# **testBodyWithFileSchema** -> testBodyWithFileSchema(fileSchemaTestClass) - - - -For this test, the body for this request much reference a schema named `File`. - -### Example -```java -// Import classes: -import org.openapitools.client.ApiClient; -import org.openapitools.client.ApiException; -import org.openapitools.client.Configuration; -import org.openapitools.client.models.*; -import org.openapitools.client.api.FakeApi; - -public class Example { - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); - - FakeApi apiInstance = new FakeApi(defaultClient); - FileSchemaTestClass fileSchemaTestClass = new FileSchemaTestClass(); // FileSchemaTestClass | - try { - apiInstance.testBodyWithFileSchema(fileSchemaTestClass); - } catch (ApiException e) { - - } - } -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **fileSchemaTestClass** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Success | - | - # **testBodyWithQueryParams** > testBodyWithQueryParams(query, user) diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/docs/ModelFile.md b/samples/client/petstore/java/okhttp-gson-nextgen/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/docs/ModelList.md b/samples/client/petstore/java/okhttp-gson-nextgen/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/docs/PetWithRequiredTags.md b/samples/client/petstore/java/okhttp-gson-nextgen/docs/PetWithRequiredTags.md new file mode 100644 index 000000000000..16525294ccd8 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/docs/PetWithRequiredTags.md @@ -0,0 +1,28 @@ + + +# PetWithRequiredTags + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **List<String>** | | +**tags** | [**List<Tag>**](Tag.md) | | +**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/okhttp-gson-nextgen/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/JSON.java index 40146a3e6f5f..584a6e970c8f 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/JSON.java @@ -47,13 +47,13 @@ * backward-compatibility */ 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(); - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); @SuppressWarnings("unchecked") public static GsonBuilder createGson() { @@ -213,7 +213,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri return clazz; } - public JSON() { + { gson = createGson() .registerTypeAdapter(Date.class, dateTypeAdapter) .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) @@ -244,7 +244,6 @@ public JSON() { .registerTypeAdapterFactory(new org.openapitools.client.model.EnumArrays.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.EnumTest.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.EquilateralTriangle.CustomTypeAdapterFactory()) - .registerTypeAdapterFactory(new org.openapitools.client.model.FileSchemaTestClass.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.Foo.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.FormatTest.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.Fruit.CustomTypeAdapterFactory()) @@ -269,6 +268,7 @@ public JSON() { .registerTypeAdapterFactory(new org.openapitools.client.model.OuterComposite.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.ParentPet.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory()) + .registerTypeAdapterFactory(new org.openapitools.client.model.PetWithRequiredTags.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.Pig.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.Quadrilateral.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new org.openapitools.client.model.QuadrilateralInterface.CustomTypeAdapterFactory()) @@ -293,7 +293,7 @@ public JSON() { * * @return Gson */ - public Gson getGson() { + public static Gson getGson() { return gson; } @@ -302,11 +302,11 @@ public Gson getGson() { * * @param gson Gson */ - public void setGson(Gson gson) { - this.gson = gson; + public static void setGson(Gson gson) { + JSON.gson = gson; } - public void setLenientOnJson(boolean lenientOnJson) { + public static void setLenientOnJson(boolean lenientOnJson) { isLenientOnJson = lenientOnJson; } @@ -316,7 +316,7 @@ public void setLenientOnJson(boolean lenientOnJson) { * @param obj Object * @return String representation of the JSON */ - public String serialize(Object obj) { + public static String serialize(Object obj) { return gson.toJson(obj); } @@ -329,7 +329,7 @@ public String serialize(Object obj) { * @return The deserialized Java object */ @SuppressWarnings("unchecked") - public T deserialize(String body, Type returnType) { + public static T deserialize(String body, Type returnType) { try { if (isLenientOnJson) { JsonReader jsonReader = new JsonReader(new StringReader(body)); @@ -353,7 +353,7 @@ public T deserialize(String body, Type returnType) { /** * Gson TypeAdapter for Byte Array type */ - public class ByteArrayAdapter extends TypeAdapter { + public static class ByteArrayAdapter extends TypeAdapter { @Override public void write(JsonWriter out, byte[] value) throws IOException { @@ -381,7 +381,7 @@ public byte[] read(JsonReader in) throws IOException { /** * Gson TypeAdapter for JSR310 OffsetDateTime type */ - public class OffsetDateTimeTypeAdapter extends TypeAdapter { + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { private DateTimeFormatter formatter; @@ -425,7 +425,7 @@ public OffsetDateTime read(JsonReader in) throws IOException { /** * Gson TypeAdapter for JSR310 LocalDate type */ - public class LocalDateTypeAdapter extends TypeAdapter { + public static class LocalDateTypeAdapter extends TypeAdapter { private DateTimeFormatter formatter; @@ -463,11 +463,11 @@ public LocalDate read(JsonReader in) throws IOException { } } - public void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { offsetDateTimeTypeAdapter.setFormat(dateFormat); } - public void setLocalDateFormat(DateTimeFormatter dateFormat) { + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { localDateTypeAdapter.setFormat(dateFormat); } @@ -476,7 +476,7 @@ public void setLocalDateFormat(DateTimeFormatter dateFormat) { * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used * (more efficient than SimpleDateFormat). */ - public class SqlDateTypeAdapter extends TypeAdapter { + public static class SqlDateTypeAdapter extends TypeAdapter { private DateFormat dateFormat; @@ -529,7 +529,7 @@ public java.sql.Date read(JsonReader in) throws IOException { * Gson TypeAdapter for java.util.Date type * If the dateFormat is null, ISO8601Utils will be used. */ - public class DateTypeAdapter extends TypeAdapter { + public static class DateTypeAdapter extends TypeAdapter { private DateFormat dateFormat; @@ -582,11 +582,11 @@ public Date read(JsonReader in) throws IOException { } } - public void setDateFormat(DateFormat dateFormat) { + public static void setDateFormat(DateFormat dateFormat) { dateTypeAdapter.setFormat(dateFormat); } - public void setSqlDateFormat(DateFormat dateFormat) { + public static void setSqlDateFormat(DateFormat dateFormat) { sqlDateTypeAdapter.setFormat(dateFormat); } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java index 271df76973e0..50c9b922e985 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java @@ -30,7 +30,6 @@ import java.math.BigDecimal; import org.openapitools.client.model.Client; import java.io.File; -import org.openapitools.client.model.FileSchemaTestClass; import org.openapitools.client.model.HealthCheckResult; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; @@ -740,115 +739,6 @@ public okhttp3.Call getArrayOfEnumsAsync(final ApiCallback> _cal localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - /** - * Build call for testBodyWithFileSchema - * @param fileSchemaTestClass (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - -
Status Code Description Response Headers
200 Success -
- */ - public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass fileSchemaTestClass, final ApiCallback _callback) throws ApiException { - Object localVarPostBody = fileSchemaTestClass; - - // create path and map variables - String localVarPath = "/fake/body-with-file-schema"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call testBodyWithFileSchemaValidateBeforeCall(FileSchemaTestClass fileSchemaTestClass, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'fileSchemaTestClass' is set - if (fileSchemaTestClass == null) { - throw new ApiException("Missing the required parameter 'fileSchemaTestClass' when calling testBodyWithFileSchema(Async)"); - } - - - okhttp3.Call localVarCall = testBodyWithFileSchemaCall(fileSchemaTestClass, _callback); - return localVarCall; - - } - - /** - * - * For this test, the body for this request much reference a schema named `File`. - * @param fileSchemaTestClass (required) - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - -
Status Code Description Response Headers
200 Success -
- */ - public void testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) throws ApiException { - testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); - } - - /** - * - * For this test, the body for this request much reference a schema named `File`. - * @param fileSchemaTestClass (required) - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - -
Status Code Description Response Headers
200 Success -
- */ - public ApiResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass) throws ApiException { - okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(fileSchemaTestClass, null); - return localVarApiClient.execute(localVarCall); - } - - /** - * (asynchronously) - * For this test, the body for this request much reference a schema named `File`. - * @param fileSchemaTestClass (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - -
Status Code Description Response Headers
200 Success -
- */ - public okhttp3.Call testBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(fileSchemaTestClass, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } /** * Build call for testBodyWithQueryParams * @param query (required) diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java index 5c1d5c3fd664..d5f4dc14d804 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java @@ -30,6 +30,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -44,6 +45,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * AdditionalPropertiesClass */ @@ -362,6 +365,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -381,6 +385,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesClass + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesClass is not found in the empty JSON string", AdditionalPropertiesClass.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdditionalPropertiesClass.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -401,19 +428,33 @@ public void write(JsonWriter out, AdditionalPropertiesClass value) throws IOExce @Override public AdditionalPropertiesClass read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!AdditionalPropertiesClass.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `AdditionalPropertiesClass` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of AdditionalPropertiesClass given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdditionalPropertiesClass + * @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesClass + */ + public static AdditionalPropertiesClass fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdditionalPropertiesClass.class); + } + + /** + * Convert an instance of AdditionalPropertiesClass to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Animal.java index 4d60101ca177..de69f3d6d73c 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Animal.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Animal.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Animal */ @@ -144,4 +147,68 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("className"); + openapiFields.add("color"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("className"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Animal + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Animal.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Animal is not found in the empty JSON string", Animal.openapiRequiredFields.toString())); + } + } + + String discriminatorValue = jsonObj.get("className").getAsString(); + switch (discriminatorValue) { + case "Cat": + Cat.validateJsonObject(jsonObj); + break; + case "Dog": + Dog.validateJsonObject(jsonObj); + break; + default: + throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue)); + } + } + + + /** + * Create an instance of Animal given an JSON string + * + * @param jsonString JSON string + * @return An instance of Animal + * @throws IOException if the JSON string is invalid with respect to Animal + */ + public static Animal fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Animal.class); + } + + /** + * Convert an instance of Animal to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Apple.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Apple.java index 03e3cc0f9c8d..650f2483d018 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Apple.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Apple.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Apple */ @@ -141,6 +144,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -154,6 +158,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Apple + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Apple.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Apple is not found in the empty JSON string", Apple.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Apple.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Apple` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -174,19 +201,33 @@ public void write(JsonWriter out, Apple value) throws IOException { @Override public Apple read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Apple.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Apple` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Apple given an JSON string + * + * @param jsonString JSON string + * @return An instance of Apple + * @throws IOException if the JSON string is invalid with respect to Apple + */ + public static Apple fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Apple.class); + } + + /** + * Convert an instance of Apple to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AppleReq.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AppleReq.java index dbf822795342..9270ce0a1836 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AppleReq.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/AppleReq.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * AppleReq */ @@ -141,6 +144,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -155,6 +159,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("cultivar"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AppleReq + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (AppleReq.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in AppleReq is not found in the empty JSON string", AppleReq.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AppleReq.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AppleReq` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AppleReq.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -175,26 +209,33 @@ public void write(JsonWriter out, AppleReq value) throws IOException { @Override public AppleReq read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!AppleReq.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `AppleReq` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : AppleReq.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of AppleReq given an JSON string + * + * @param jsonString JSON string + * @return An instance of AppleReq + * @throws IOException if the JSON string is invalid with respect to AppleReq + */ + public static AppleReq fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AppleReq.class); + } + + /** + * Convert an instance of AppleReq to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java index 2dc3a6954049..d375bd8a4886 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java @@ -29,6 +29,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -43,6 +44,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ArrayOfArrayOfNumberOnly */ @@ -123,6 +126,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -135,6 +139,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ArrayOfArrayOfNumberOnly + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfArrayOfNumberOnly is not found in the empty JSON string", ArrayOfArrayOfNumberOnly.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ArrayOfArrayOfNumberOnly.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -155,19 +182,33 @@ public void write(JsonWriter out, ArrayOfArrayOfNumberOnly value) throws IOExcep @Override public ArrayOfArrayOfNumberOnly read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ArrayOfArrayOfNumberOnly.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ArrayOfArrayOfNumberOnly given an JSON string + * + * @param jsonString JSON string + * @return An instance of ArrayOfArrayOfNumberOnly + * @throws IOException if the JSON string is invalid with respect to ArrayOfArrayOfNumberOnly + */ + public static ArrayOfArrayOfNumberOnly fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ArrayOfArrayOfNumberOnly.class); + } + + /** + * Convert an instance of ArrayOfArrayOfNumberOnly to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java index 384759be851e..9ec157ed1515 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java @@ -29,6 +29,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -43,6 +44,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ArrayOfNumberOnly */ @@ -123,6 +126,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -135,6 +139,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ArrayOfNumberOnly + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfNumberOnly is not found in the empty JSON string", ArrayOfNumberOnly.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ArrayOfNumberOnly.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -155,19 +182,33 @@ public void write(JsonWriter out, ArrayOfNumberOnly value) throws IOException { @Override public ArrayOfNumberOnly read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ArrayOfNumberOnly.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ArrayOfNumberOnly` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ArrayOfNumberOnly given an JSON string + * + * @param jsonString JSON string + * @return An instance of ArrayOfNumberOnly + * @throws IOException if the JSON string is invalid with respect to ArrayOfNumberOnly + */ + public static ArrayOfNumberOnly fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ArrayOfNumberOnly.class); + } + + /** + * Convert an instance of ArrayOfNumberOnly to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayTest.java index 23c8d4fbd1b2..66d23d236a84 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayTest.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ArrayTest.java @@ -29,6 +29,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -43,6 +44,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ArrayTest */ @@ -197,6 +200,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -211,6 +215,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ArrayTest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ArrayTest.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayTest is not found in the empty JSON string", ArrayTest.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ArrayTest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -231,19 +258,33 @@ public void write(JsonWriter out, ArrayTest value) throws IOException { @Override public ArrayTest read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ArrayTest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ArrayTest` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ArrayTest given an JSON string + * + * @param jsonString JSON string + * @return An instance of ArrayTest + * @throws IOException if the JSON string is invalid with respect to ArrayTest + */ + public static ArrayTest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ArrayTest.class); + } + + /** + * Convert an instance of ArrayTest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Banana.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Banana.java index e409ac6907a0..7ce5f0328cb4 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Banana.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Banana.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Banana */ @@ -113,6 +116,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Banana + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Banana.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Banana is not found in the empty JSON string", Banana.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Banana.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Banana` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,19 +172,33 @@ public void write(JsonWriter out, Banana value) throws IOException { @Override public Banana read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Banana.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Banana` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Banana given an JSON string + * + * @param jsonString JSON string + * @return An instance of Banana + * @throws IOException if the JSON string is invalid with respect to Banana + */ + public static Banana fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Banana.class); + } + + /** + * Convert an instance of Banana to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BananaReq.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BananaReq.java index 7955096b5d3c..9691c1427ab8 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BananaReq.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BananaReq.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * BananaReq */ @@ -142,6 +145,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -156,6 +160,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("lengthCm"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BananaReq + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (BananaReq.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in BananaReq is not found in the empty JSON string", BananaReq.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!BananaReq.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BananaReq` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BananaReq.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -176,26 +210,33 @@ public void write(JsonWriter out, BananaReq value) throws IOException { @Override public BananaReq read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!BananaReq.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `BananaReq` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : BananaReq.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of BananaReq given an JSON string + * + * @param jsonString JSON string + * @return An instance of BananaReq + * @throws IOException if the JSON string is invalid with respect to BananaReq + */ + public static BananaReq fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BananaReq.class); + } + + /** + * Convert an instance of BananaReq to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BasquePig.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BasquePig.java index 93fc4cad0b9e..158472221c29 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BasquePig.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/BasquePig.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * BasquePig */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("className"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BasquePig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (BasquePig.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in BasquePig is not found in the empty JSON string", BasquePig.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!BasquePig.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BasquePig` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BasquePig.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,26 +179,33 @@ public void write(JsonWriter out, BasquePig value) throws IOException { @Override public BasquePig read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!BasquePig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `BasquePig` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : BasquePig.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of BasquePig given an JSON string + * + * @param jsonString JSON string + * @return An instance of BasquePig + * @throws IOException if the JSON string is invalid with respect to BasquePig + */ + public static BasquePig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BasquePig.class); + } + + /** + * Convert an instance of BasquePig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Capitalization.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Capitalization.java index eceb83bbfeb0..ce4095ed0e52 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Capitalization.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Capitalization.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Capitalization */ @@ -257,6 +260,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -274,6 +278,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Capitalization + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Capitalization.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Capitalization is not found in the empty JSON string", Capitalization.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Capitalization.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -294,19 +321,33 @@ public void write(JsonWriter out, Capitalization value) throws IOException { @Override public Capitalization read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Capitalization.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Capitalization` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Capitalization given an JSON string + * + * @param jsonString JSON string + * @return An instance of Capitalization + * @throws IOException if the JSON string is invalid with respect to Capitalization + */ + public static Capitalization fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Capitalization.class); + } + + /** + * Convert an instance of Capitalization to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Cat.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Cat.java index 426511dc3c0a..a81d5016bf72 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Cat.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Cat.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Cat */ @@ -117,6 +120,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -132,6 +136,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("className"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Cat + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Cat.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Cat is not found in the empty JSON string", Cat.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Cat.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Cat` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Cat.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -152,26 +186,33 @@ public void write(JsonWriter out, Cat value) throws IOException { @Override public Cat read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Cat.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Cat` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Cat.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Cat given an JSON string + * + * @param jsonString JSON string + * @return An instance of Cat + * @throws IOException if the JSON string is invalid with respect to Cat + */ + public static Cat fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Cat.class); + } + + /** + * Convert an instance of Cat to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/CatAllOf.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/CatAllOf.java index 8d9affba3dc7..6a2c50e1c046 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/CatAllOf.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/CatAllOf.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * CatAllOf */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -124,6 +128,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CatAllOf + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (CatAllOf.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in CatAllOf is not found in the empty JSON string", CatAllOf.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!CatAllOf.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CatAllOf` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -144,19 +171,33 @@ public void write(JsonWriter out, CatAllOf value) throws IOException { @Override public CatAllOf read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!CatAllOf.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `CatAllOf` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of CatAllOf given an JSON string + * + * @param jsonString JSON string + * @return An instance of CatAllOf + * @throws IOException if the JSON string is invalid with respect to CatAllOf + */ + public static CatAllOf fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CatAllOf.class); + } + + /** + * Convert an instance of CatAllOf to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Category.java index 85eb92c71b2a..d23447f518de 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Category.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Category */ @@ -141,6 +144,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -155,6 +159,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("name"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Category + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Category.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Category is not found in the empty JSON string", Category.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Category.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Category.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -175,26 +209,33 @@ public void write(JsonWriter out, Category value) throws IOException { @Override public Category read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Category.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Category` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Category.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Category given an JSON string + * + * @param jsonString JSON string + * @return An instance of Category + * @throws IOException if the JSON string is invalid with respect to Category + */ + public static Category fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Category.class); + } + + /** + * Convert an instance of Category to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ClassModel.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ClassModel.java index da8517ec7b90..8fb1b2f83d15 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ClassModel.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ClassModel.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Model for testing model with \"_class\" property */ @@ -113,6 +116,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ClassModel + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ClassModel.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ClassModel is not found in the empty JSON string", ClassModel.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ClassModel.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,19 +172,33 @@ public void write(JsonWriter out, ClassModel value) throws IOException { @Override public ClassModel read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ClassModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ClassModel` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ClassModel given an JSON string + * + * @param jsonString JSON string + * @return An instance of ClassModel + * @throws IOException if the JSON string is invalid with respect to ClassModel + */ + public static ClassModel fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ClassModel.class); + } + + /** + * Convert an instance of ClassModel to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Client.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Client.java index 2a7cf96170ca..a52cc0be31af 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Client.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Client.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Client */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -124,6 +128,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Client + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Client.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Client is not found in the empty JSON string", Client.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Client.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -144,19 +171,33 @@ public void write(JsonWriter out, Client value) throws IOException { @Override public Client read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Client.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Client` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Client given an JSON string + * + * @param jsonString JSON string + * @return An instance of Client + * @throws IOException if the JSON string is invalid with respect to Client + */ + public static Client fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Client.class); + } + + /** + * Convert an instance of Client to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ComplexQuadrilateral.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ComplexQuadrilateral.java index 197a8ca0a229..c604f41f8b72 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ComplexQuadrilateral.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ComplexQuadrilateral.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ComplexQuadrilateral */ @@ -143,6 +146,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -158,6 +162,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("quadrilateralType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ComplexQuadrilateral + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ComplexQuadrilateral.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ComplexQuadrilateral is not found in the empty JSON string", ComplexQuadrilateral.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ComplexQuadrilateral.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ComplexQuadrilateral` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ComplexQuadrilateral.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -178,26 +212,33 @@ public void write(JsonWriter out, ComplexQuadrilateral value) throws IOException @Override public ComplexQuadrilateral read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ComplexQuadrilateral.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ComplexQuadrilateral` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ComplexQuadrilateral.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ComplexQuadrilateral given an JSON string + * + * @param jsonString JSON string + * @return An instance of ComplexQuadrilateral + * @throws IOException if the JSON string is invalid with respect to ComplexQuadrilateral + */ + public static ComplexQuadrilateral fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ComplexQuadrilateral.class); + } + + /** + * Convert an instance of ComplexQuadrilateral to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DanishPig.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DanishPig.java index c9bdd6fb478b..6083d1cc0131 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DanishPig.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DanishPig.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * DanishPig */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("className"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DanishPig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (DanishPig.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in DanishPig is not found in the empty JSON string", DanishPig.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!DanishPig.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DanishPig` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DanishPig.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,26 +179,33 @@ public void write(JsonWriter out, DanishPig value) throws IOException { @Override public DanishPig read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!DanishPig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `DanishPig` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : DanishPig.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of DanishPig given an JSON string + * + * @param jsonString JSON string + * @return An instance of DanishPig + * @throws IOException if the JSON string is invalid with respect to DanishPig + */ + public static DanishPig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DanishPig.class); + } + + /** + * Convert an instance of DanishPig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DeprecatedObject.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DeprecatedObject.java index 1ebdc75845ba..9bab6c77d617 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DeprecatedObject.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * DeprecatedObject * @deprecated @@ -114,6 +117,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -126,6 +130,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DeprecatedObject + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (DeprecatedObject.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in DeprecatedObject is not found in the empty JSON string", DeprecatedObject.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!DeprecatedObject.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DeprecatedObject` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -146,19 +173,33 @@ public void write(JsonWriter out, DeprecatedObject value) throws IOException { @Override public DeprecatedObject read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!DeprecatedObject.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `DeprecatedObject` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of DeprecatedObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of DeprecatedObject + * @throws IOException if the JSON string is invalid with respect to DeprecatedObject + */ + public static DeprecatedObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DeprecatedObject.class); + } + + /** + * Convert an instance of DeprecatedObject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Dog.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Dog.java index 407d20c326a9..24062284ab56 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Dog.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Dog.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Dog */ @@ -117,6 +120,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -132,6 +136,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("className"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Dog + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Dog.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Dog is not found in the empty JSON string", Dog.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Dog.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Dog.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -152,26 +186,33 @@ public void write(JsonWriter out, Dog value) throws IOException { @Override public Dog read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Dog.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Dog` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Dog.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Dog given an JSON string + * + * @param jsonString JSON string + * @return An instance of Dog + * @throws IOException if the JSON string is invalid with respect to Dog + */ + public static Dog fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Dog.class); + } + + /** + * Convert an instance of Dog to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DogAllOf.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DogAllOf.java index 4305b501e06d..6053b9169b79 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DogAllOf.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/DogAllOf.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * DogAllOf */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -124,6 +128,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DogAllOf + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (DogAllOf.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in DogAllOf is not found in the empty JSON string", DogAllOf.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!DogAllOf.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DogAllOf` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -144,19 +171,33 @@ public void write(JsonWriter out, DogAllOf value) throws IOException { @Override public DogAllOf read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!DogAllOf.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `DogAllOf` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of DogAllOf given an JSON string + * + * @param jsonString JSON string + * @return An instance of DogAllOf + * @throws IOException if the JSON string is invalid with respect to DogAllOf + */ + public static DogAllOf fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DogAllOf.class); + } + + /** + * Convert an instance of DogAllOf to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Drawing.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Drawing.java index b880f4c49dd7..793d088bad2b 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Drawing.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Drawing.java @@ -35,6 +35,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -49,6 +50,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Drawing */ @@ -229,6 +232,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -244,6 +248,48 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Drawing + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Drawing.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Drawing is not found in the empty JSON string", Drawing.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Drawing.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Drawing` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `mainShape` + if (jsonObj.getAsJsonObject("mainShape") != null) { + Shape.validateJsonObject(jsonObj.getAsJsonObject("mainShape")); + } + // validate the optional field `shapeOrNull` + if (jsonObj.getAsJsonObject("shapeOrNull") != null) { + ShapeOrNull.validateJsonObject(jsonObj.getAsJsonObject("shapeOrNull")); + } + // validate the optional field `nullableShape` + if (jsonObj.getAsJsonObject("nullableShape") != null) { + NullableShape.validateJsonObject(jsonObj.getAsJsonObject("nullableShape")); + } + JsonArray jsonArrayshapes = jsonObj.getAsJsonArray("shapes"); + // validate the optional field `shapes` (array) + if (jsonArrayshapes != null) { + for (int i = 0; i < jsonArrayshapes.size(); i++) { + Shape.validateJsonObject(jsonArrayshapes.get(i).getAsJsonObject()); + }; + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -264,19 +310,33 @@ public void write(JsonWriter out, Drawing value) throws IOException { @Override public Drawing read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Drawing.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Drawing` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Drawing given an JSON string + * + * @param jsonString JSON string + * @return An instance of Drawing + * @throws IOException if the JSON string is invalid with respect to Drawing + */ + public static Drawing fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Drawing.class); + } + + /** + * Convert an instance of Drawing to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumArrays.java index 87675e4eef79..6b64ece26660 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * EnumArrays */ @@ -245,6 +248,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -258,6 +262,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to EnumArrays + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (EnumArrays.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in EnumArrays is not found in the empty JSON string", EnumArrays.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!EnumArrays.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -278,19 +305,33 @@ public void write(JsonWriter out, EnumArrays value) throws IOException { @Override public EnumArrays read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!EnumArrays.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `EnumArrays` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of EnumArrays given an JSON string + * + * @param jsonString JSON string + * @return An instance of EnumArrays + * @throws IOException if the JSON string is invalid with respect to EnumArrays + */ + public static EnumArrays fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EnumArrays.class); + } + + /** + * Convert an instance of EnumArrays to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumTest.java index 8bb57d811f05..b25fad66483e 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EnumTest.java @@ -31,6 +31,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -45,6 +46,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * EnumTest */ @@ -599,6 +602,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -620,6 +624,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("enum_string_required"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to EnumTest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (EnumTest.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in EnumTest is not found in the empty JSON string", EnumTest.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!EnumTest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumTest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EnumTest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -640,26 +674,33 @@ public void write(JsonWriter out, EnumTest value) throws IOException { @Override public EnumTest read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!EnumTest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `EnumTest` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : EnumTest.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of EnumTest given an JSON string + * + * @param jsonString JSON string + * @return An instance of EnumTest + * @throws IOException if the JSON string is invalid with respect to EnumTest + */ + public static EnumTest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EnumTest.class); + } + + /** + * Convert an instance of EnumTest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EquilateralTriangle.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EquilateralTriangle.java index d0d2a26dab70..a2cf60f6b1c1 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EquilateralTriangle.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/EquilateralTriangle.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * EquilateralTriangle */ @@ -143,6 +146,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -158,6 +162,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("triangleType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to EquilateralTriangle + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (EquilateralTriangle.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in EquilateralTriangle is not found in the empty JSON string", EquilateralTriangle.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!EquilateralTriangle.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EquilateralTriangle` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EquilateralTriangle.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -178,26 +212,33 @@ public void write(JsonWriter out, EquilateralTriangle value) throws IOException @Override public EquilateralTriangle read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!EquilateralTriangle.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `EquilateralTriangle` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : EquilateralTriangle.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of EquilateralTriangle given an JSON string + * + * @param jsonString JSON string + * @return An instance of EquilateralTriangle + * @throws IOException if the JSON string is invalid with respect to EquilateralTriangle + */ + public static EquilateralTriangle fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EquilateralTriangle.class); + } + + /** + * Convert an instance of EquilateralTriangle to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Foo.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Foo.java index 61d7be45d63d..574dbb34592c 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Foo.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Foo.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Foo */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -124,6 +128,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Foo + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Foo.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Foo is not found in the empty JSON string", Foo.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Foo.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Foo` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -144,19 +171,33 @@ public void write(JsonWriter out, Foo value) throws IOException { @Override public Foo read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Foo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Foo` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Foo given an JSON string + * + * @param jsonString JSON string + * @return An instance of Foo + * @throws IOException if the JSON string is invalid with respect to Foo + */ + public static Foo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Foo.class); + } + + /** + * Convert an instance of Foo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FormatTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FormatTest.java index a5b0cbf197f5..48923c990846 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FormatTest.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FormatTest.java @@ -31,6 +31,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -45,6 +46,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * FormatTest */ @@ -562,6 +565,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -593,6 +597,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("password"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FormatTest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (FormatTest.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in FormatTest is not found in the empty JSON string", FormatTest.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!FormatTest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FormatTest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FormatTest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -613,26 +647,33 @@ public void write(JsonWriter out, FormatTest value) throws IOException { @Override public FormatTest read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!FormatTest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `FormatTest` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : FormatTest.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of FormatTest given an JSON string + * + * @param jsonString JSON string + * @return An instance of FormatTest + * @throws IOException if the JSON string is invalid with respect to FormatTest + */ + public static FormatTest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FormatTest.class); + } + + /** + * Convert an instance of FormatTest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Fruit.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Fruit.java index 7ed501ad6df0..b23b5c19d2ba 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Fruit.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Fruit.java @@ -106,10 +106,13 @@ public Fruit read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize Apple try { - deserialized = adapterApple.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Apple.validateJsonObject(jsonObject); + actualAdapter = adapterApple; match++; log.log(Level.FINER, "Input data matches schema 'Apple'"); } catch (Exception e) { @@ -119,7 +122,9 @@ public Fruit read(JsonReader in) throws IOException { // deserialize Banana try { - deserialized = adapterBanana.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Banana.validateJsonObject(jsonObject); + actualAdapter = adapterBanana; match++; log.log(Level.FINER, "Input data matches schema 'Banana'"); } catch (Exception e) { @@ -129,7 +134,7 @@ public Fruit read(JsonReader in) throws IOException { if (match == 1) { Fruit ret = new Fruit(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -224,5 +229,53 @@ public Banana getBanana() throws ClassCastException { return (Banana)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Fruit + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with Apple + try { + Apple.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Banana + try { + Banana.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for Fruit with oneOf schemas: Apple, Banana. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of Fruit given an JSON string + * + * @param jsonString JSON string + * @return An instance of Fruit + * @throws IOException if the JSON string is invalid with respect to Fruit + */ + public static Fruit fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Fruit.class); + } + + /** + * Convert an instance of Fruit to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FruitReq.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FruitReq.java index 5c886b122bcb..abaf8b2fc6d8 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FruitReq.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FruitReq.java @@ -106,10 +106,13 @@ public FruitReq read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize AppleReq try { - deserialized = adapterAppleReq.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + AppleReq.validateJsonObject(jsonObject); + actualAdapter = adapterAppleReq; match++; log.log(Level.FINER, "Input data matches schema 'AppleReq'"); } catch (Exception e) { @@ -119,7 +122,9 @@ public FruitReq read(JsonReader in) throws IOException { // deserialize BananaReq try { - deserialized = adapterBananaReq.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + BananaReq.validateJsonObject(jsonObject); + actualAdapter = adapterBananaReq; match++; log.log(Level.FINER, "Input data matches schema 'BananaReq'"); } catch (Exception e) { @@ -129,7 +134,7 @@ public FruitReq read(JsonReader in) throws IOException { if (match == 1) { FruitReq ret = new FruitReq(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -229,5 +234,53 @@ public BananaReq getBananaReq() throws ClassCastException { return (BananaReq)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FruitReq + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with AppleReq + try { + AppleReq.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with BananaReq + try { + BananaReq.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for FruitReq with oneOf schemas: AppleReq, BananaReq. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of FruitReq given an JSON string + * + * @param jsonString JSON string + * @return An instance of FruitReq + * @throws IOException if the JSON string is invalid with respect to FruitReq + */ + public static FruitReq fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FruitReq.class); + } + + /** + * Convert an instance of FruitReq to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GmFruit.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GmFruit.java index 36a4bd8b2489..eec085e78edf 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GmFruit.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GmFruit.java @@ -105,13 +105,13 @@ public GmFruit read(JsonReader in) throws IOException { Object deserialized = null; JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); - // deserialize Apple try { - deserialized = adapterApple.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Apple.validateJsonObject(jsonObject); log.log(Level.FINER, "Input data matches schema 'Apple'"); GmFruit ret = new GmFruit(); - ret.setActualInstance(deserialized); + ret.setActualInstance(adapterApple.fromJsonTree(jsonObject)); return ret; } catch (Exception e) { // deserialization failed, continue @@ -120,17 +120,19 @@ public GmFruit read(JsonReader in) throws IOException { // deserialize Banana try { - deserialized = adapterBanana.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Banana.validateJsonObject(jsonObject); log.log(Level.FINER, "Input data matches schema 'Banana'"); GmFruit ret = new GmFruit(); - ret.setActualInstance(deserialized); + ret.setActualInstance(adapterBanana.fromJsonTree(jsonObject)); return ret; } catch (Exception e) { // deserialization failed, continue log.log(Level.FINER, "Input data does not match schema 'Banana'", e); } - throw new IOException(String.format("Failed deserialization for GmFruit as data doesn't match anyOf schmeas: Apple, Banana. JSON: %s", jsonObject.toString())); + + throw new IOException(String.format("Failed deserialization for GmFruit: no class matched. JSON: %s", jsonObject.toString())); } }.nullSafe(); } @@ -221,5 +223,55 @@ public Banana getBanana() throws ClassCastException { return (Banana)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GmFruit + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with Apple + try { + Apple.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Banana + try { + Banana.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for GmFruit with anyOf schemas: Apple, Banana. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of GmFruit given an JSON string + * + * @param jsonString JSON string + * @return An instance of GmFruit + * @throws IOException if the JSON string is invalid with respect to GmFruit + */ + public static GmFruit fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GmFruit.class); + } + + /** + * Convert an instance of GmFruit to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GrandparentAnimal.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GrandparentAnimal.java index 085ccbfbfc1c..a5f1f9ff349f 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GrandparentAnimal.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/GrandparentAnimal.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * GrandparentAnimal */ @@ -114,4 +117,64 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("pet_type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("pet_type"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GrandparentAnimal + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (GrandparentAnimal.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in GrandparentAnimal is not found in the empty JSON string", GrandparentAnimal.openapiRequiredFields.toString())); + } + } + + String discriminatorValue = jsonObj.get("pet_type").getAsString(); + switch (discriminatorValue) { + case "ParentPet": + ParentPet.validateJsonObject(jsonObj); + break; + default: + throw new IllegalArgumentException(String.format("The value of the `pet_type` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue)); + } + } + + + /** + * Create an instance of GrandparentAnimal given an JSON string + * + * @param jsonString JSON string + * @return An instance of GrandparentAnimal + * @throws IOException if the JSON string is invalid with respect to GrandparentAnimal + */ + public static GrandparentAnimal fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GrandparentAnimal.class); + } + + /** + * Convert an instance of GrandparentAnimal to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java index 31a4a05a3d5c..ff80990e36a7 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * HasOnlyReadOnly */ @@ -133,6 +136,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -146,6 +150,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HasOnlyReadOnly + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (HasOnlyReadOnly.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in HasOnlyReadOnly is not found in the empty JSON string", HasOnlyReadOnly.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HasOnlyReadOnly.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HasOnlyReadOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -166,19 +193,33 @@ public void write(JsonWriter out, HasOnlyReadOnly value) throws IOException { @Override public HasOnlyReadOnly read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!HasOnlyReadOnly.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `HasOnlyReadOnly` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of HasOnlyReadOnly given an JSON string + * + * @param jsonString JSON string + * @return An instance of HasOnlyReadOnly + * @throws IOException if the JSON string is invalid with respect to HasOnlyReadOnly + */ + public static HasOnlyReadOnly fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HasOnlyReadOnly.class); + } + + /** + * Convert an instance of HasOnlyReadOnly to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HealthCheckResult.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HealthCheckResult.java index 8af6fca3706a..bc48571626b0 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HealthCheckResult.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/HealthCheckResult.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. */ @@ -125,6 +128,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -137,6 +141,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to HealthCheckResult + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (HealthCheckResult.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in HealthCheckResult is not found in the empty JSON string", HealthCheckResult.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!HealthCheckResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HealthCheckResult` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -157,19 +184,33 @@ public void write(JsonWriter out, HealthCheckResult value) throws IOException { @Override public HealthCheckResult read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!HealthCheckResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `HealthCheckResult` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of HealthCheckResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of HealthCheckResult + * @throws IOException if the JSON string is invalid with respect to HealthCheckResult + */ + public static HealthCheckResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HealthCheckResult.class); + } + + /** + * Convert an instance of HealthCheckResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/InlineResponseDefault.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/InlineResponseDefault.java index 925d6c646c99..5f0873c2b157 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/InlineResponseDefault.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/InlineResponseDefault.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * InlineResponseDefault */ @@ -113,6 +116,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,33 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to InlineResponseDefault + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (InlineResponseDefault.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in InlineResponseDefault is not found in the empty JSON string", InlineResponseDefault.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!InlineResponseDefault.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `InlineResponseDefault` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `string` + if (jsonObj.getAsJsonObject("string") != null) { + Foo.validateJsonObject(jsonObj.getAsJsonObject("string")); + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,19 +176,33 @@ public void write(JsonWriter out, InlineResponseDefault value) throws IOExceptio @Override public InlineResponseDefault read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!InlineResponseDefault.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `InlineResponseDefault` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of InlineResponseDefault given an JSON string + * + * @param jsonString JSON string + * @return An instance of InlineResponseDefault + * @throws IOException if the JSON string is invalid with respect to InlineResponseDefault + */ + public static InlineResponseDefault fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, InlineResponseDefault.class); + } + + /** + * Convert an instance of InlineResponseDefault to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/IsoscelesTriangle.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/IsoscelesTriangle.java index 2c2a44565513..27a25ee3f6e1 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/IsoscelesTriangle.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/IsoscelesTriangle.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * IsoscelesTriangle */ @@ -143,6 +146,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -158,6 +162,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("triangleType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to IsoscelesTriangle + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (IsoscelesTriangle.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in IsoscelesTriangle is not found in the empty JSON string", IsoscelesTriangle.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!IsoscelesTriangle.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `IsoscelesTriangle` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : IsoscelesTriangle.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -178,26 +212,33 @@ public void write(JsonWriter out, IsoscelesTriangle value) throws IOException { @Override public IsoscelesTriangle read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!IsoscelesTriangle.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `IsoscelesTriangle` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : IsoscelesTriangle.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of IsoscelesTriangle given an JSON string + * + * @param jsonString JSON string + * @return An instance of IsoscelesTriangle + * @throws IOException if the JSON string is invalid with respect to IsoscelesTriangle + */ + public static IsoscelesTriangle fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, IsoscelesTriangle.class); + } + + /** + * Convert an instance of IsoscelesTriangle to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Mammal.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Mammal.java index 21834a0903b4..7d10d2dfc1a4 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Mammal.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Mammal.java @@ -114,10 +114,13 @@ public Mammal read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize Pig try { - deserialized = adapterPig.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Pig.validateJsonObject(jsonObject); + actualAdapter = adapterPig; match++; log.log(Level.FINER, "Input data matches schema 'Pig'"); } catch (Exception e) { @@ -127,7 +130,9 @@ public Mammal read(JsonReader in) throws IOException { // deserialize Whale try { - deserialized = adapterWhale.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Whale.validateJsonObject(jsonObject); + actualAdapter = adapterWhale; match++; log.log(Level.FINER, "Input data matches schema 'Whale'"); } catch (Exception e) { @@ -137,7 +142,9 @@ public Mammal read(JsonReader in) throws IOException { // deserialize Zebra try { - deserialized = adapterZebra.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Zebra.validateJsonObject(jsonObject); + actualAdapter = adapterZebra; match++; log.log(Level.FINER, "Input data matches schema 'Zebra'"); } catch (Exception e) { @@ -147,7 +154,7 @@ public Mammal read(JsonReader in) throws IOException { if (match == 1) { Mammal ret = new Mammal(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -265,5 +272,60 @@ public Zebra getZebra() throws ClassCastException { return (Zebra)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Mammal + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with Pig + try { + Pig.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Whale + try { + Whale.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Zebra + try { + Zebra.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for Mammal with oneOf schemas: Pig, Whale, Zebra. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of Mammal given an JSON string + * + * @param jsonString JSON string + * @return An instance of Mammal + * @throws IOException if the JSON string is invalid with respect to Mammal + */ + public static Mammal fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Mammal.class); + } + + /** + * Convert an instance of Mammal to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MapTest.java index 615d6de35357..51fb198904fe 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MapTest.java @@ -29,6 +29,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -43,6 +44,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * MapTest */ @@ -281,6 +284,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -296,6 +300,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MapTest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (MapTest.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in MapTest is not found in the empty JSON string", MapTest.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MapTest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MapTest` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -316,19 +343,33 @@ public void write(JsonWriter out, MapTest value) throws IOException { @Override public MapTest read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!MapTest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `MapTest` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of MapTest given an JSON string + * + * @param jsonString JSON string + * @return An instance of MapTest + * @throws IOException if the JSON string is invalid with respect to MapTest + */ + public static MapTest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MapTest.class); + } + + /** + * Convert an instance of MapTest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index ae6e2282c9f9..3bd9f59adbb8 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -32,6 +32,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -46,6 +47,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * MixedPropertiesAndAdditionalPropertiesClass */ @@ -184,6 +187,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -198,6 +202,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MixedPropertiesAndAdditionalPropertiesClass + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in MixedPropertiesAndAdditionalPropertiesClass is not found in the empty JSON string", MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!MixedPropertiesAndAdditionalPropertiesClass.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -218,19 +245,33 @@ public void write(JsonWriter out, MixedPropertiesAndAdditionalPropertiesClass va @Override public MixedPropertiesAndAdditionalPropertiesClass read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!MixedPropertiesAndAdditionalPropertiesClass.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of MixedPropertiesAndAdditionalPropertiesClass given an JSON string + * + * @param jsonString JSON string + * @return An instance of MixedPropertiesAndAdditionalPropertiesClass + * @throws IOException if the JSON string is invalid with respect to MixedPropertiesAndAdditionalPropertiesClass + */ + public static MixedPropertiesAndAdditionalPropertiesClass fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MixedPropertiesAndAdditionalPropertiesClass.class); + } + + /** + * Convert an instance of MixedPropertiesAndAdditionalPropertiesClass to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Model200Response.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Model200Response.java index b9ec6bd483df..a6f1720f9e57 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Model200Response.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Model200Response.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Model for testing model name starting with number */ @@ -142,6 +145,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -155,6 +159,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Model200Response + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Model200Response.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Model200Response is not found in the empty JSON string", Model200Response.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Model200Response.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Model200Response` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -175,19 +202,33 @@ public void write(JsonWriter out, Model200Response value) throws IOException { @Override public Model200Response read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Model200Response.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Model200Response` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Model200Response given an JSON string + * + * @param jsonString JSON string + * @return An instance of Model200Response + * @throws IOException if the JSON string is invalid with respect to Model200Response + */ + public static Model200Response fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Model200Response.class); + } + + /** + * Convert an instance of Model200Response to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelApiResponse.java index c9f691d64582..9d4ee4fbdf4b 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ModelApiResponse */ @@ -170,6 +173,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -184,6 +188,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ModelApiResponse + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ModelApiResponse.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ModelApiResponse is not found in the empty JSON string", ModelApiResponse.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ModelApiResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelApiResponse` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -204,19 +231,33 @@ public void write(JsonWriter out, ModelApiResponse value) throws IOException { @Override public ModelApiResponse read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ModelApiResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ModelApiResponse` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ModelApiResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModelApiResponse + * @throws IOException if the JSON string is invalid with respect to ModelApiResponse + */ + public static ModelApiResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModelApiResponse.class); + } + + /** + * Convert an instance of ModelApiResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..4b0921084274 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,204 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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 com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sourceURI"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ModelFile + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ModelFile.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ModelFile is not found in the empty JSON string", ModelFile.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ModelFile.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelFile` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ModelFile.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ModelFile' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ModelFile.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ModelFile value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ModelFile read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ModelFile given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModelFile + * @throws IOException if the JSON string is invalid with respect to ModelFile + */ + public static ModelFile fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModelFile.class); + } + + /** + * Convert an instance of ModelFile to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelList.java similarity index 50% rename from samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java rename to samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelList.java index 9b7eb55c7484..cffa7fb4f941 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelList.java @@ -23,11 +23,10 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,73 +41,40 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** - * FileSchemaTestClass + * ModelList */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class FileSchemaTestClass { - public static final String SERIALIZED_NAME_FILE = "file"; - @SerializedName(SERIALIZED_NAME_FILE) - private java.io.File file; - - public static final String SERIALIZED_NAME_FILES = "files"; - @SerializedName(SERIALIZED_NAME_FILES) - private List files = null; +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; - public FileSchemaTestClass() { + public ModelList() { } - public FileSchemaTestClass file(java.io.File file) { + public ModelList _123list(String _123list) { - this.file = file; + this._123list = _123list; return this; } /** - * Get file - * @return file + * Get _123list + * @return _123list **/ @javax.annotation.Nullable @ApiModelProperty(value = "") - public java.io.File getFile() { - return file; - } - - - public void setFile(java.io.File file) { - this.file = file; + public String get123list() { + return _123list; } - public FileSchemaTestClass files(List files) { - - this.files = files; - return this; - } - - public FileSchemaTestClass addFilesItem(java.io.File filesItem) { - if (this.files == null) { - this.files = new ArrayList(); - } - this.files.add(filesItem); - return this; - } - - /** - * Get files - * @return files - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getFiles() { - return files; - } - - - public void setFiles(List files) { - this.files = files; + public void set123list(String _123list) { + this._123list = _123list; } @@ -120,22 +86,20 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; - return Objects.equals(this.file, fileSchemaTestClass.file) && - Objects.equals(this.files, fileSchemaTestClass.files); + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); } @Override public int hashCode() { - return Objects.hash(file, files); + return Objects.hash(_123list); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class FileSchemaTestClass {\n"); - sb.append(" file: ").append(toIndentedString(file)).append("\n"); - sb.append(" files: ").append(toIndentedString(files)).append("\n"); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,52 +115,89 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); - openapiFields.add("file"); - openapiFields.add("files"); + openapiFields.add("123-list"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ModelList + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ModelList.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ModelList is not found in the empty JSON string", ModelList.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ModelList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelList` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!FileSchemaTestClass.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'FileSchemaTestClass' and its subtypes + if (!ModelList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ModelList' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(FileSchemaTestClass.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ModelList.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, FileSchemaTestClass value) throws IOException { + public void write(JsonWriter out, ModelList value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override - public FileSchemaTestClass read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!FileSchemaTestClass.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `FileSchemaTestClass` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + public ModelList read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ModelList given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModelList + * @throws IOException if the JSON string is invalid with respect to ModelList + */ + public static ModelList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModelList.class); + } + + /** + * Convert an instance of ModelList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelReturn.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelReturn.java index 64aadfb6a824..09a6be5b714a 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelReturn.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ModelReturn.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Model for testing reserved words */ @@ -113,6 +116,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ModelReturn + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ModelReturn.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ModelReturn is not found in the empty JSON string", ModelReturn.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ModelReturn.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelReturn` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,19 +172,33 @@ public void write(JsonWriter out, ModelReturn value) throws IOException { @Override public ModelReturn read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ModelReturn.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ModelReturn` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ModelReturn given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModelReturn + * @throws IOException if the JSON string is invalid with respect to ModelReturn + */ + public static ModelReturn fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModelReturn.class); + } + + /** + * Convert an instance of ModelReturn to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Name.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Name.java index 528c159a8f37..a9f5ca0e1508 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Name.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Name.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Model for testing model name same as property name */ @@ -192,6 +195,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -208,6 +212,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("name"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Name + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Name.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Name is not found in the empty JSON string", Name.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Name.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Name` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Name.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -228,26 +262,33 @@ public void write(JsonWriter out, Name value) throws IOException { @Override public Name read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Name.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Name` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Name.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Name given an JSON string + * + * @param jsonString JSON string + * @return An instance of Name + * @throws IOException if the JSON string is invalid with respect to Name + */ + public static Name fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Name.class); + } + + /** + * Convert an instance of Name to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableClass.java index 5aa141fee0a6..cd29b3cb2ee2 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableClass.java @@ -34,6 +34,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -48,6 +49,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * NullableClass */ @@ -500,6 +503,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -523,6 +527,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NullableClass + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (NullableClass.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in NullableClass is not found in the empty JSON string", NullableClass.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!NullableClass.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NullableClass` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -543,19 +570,33 @@ public void write(JsonWriter out, NullableClass value) throws IOException { @Override public NullableClass read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!NullableClass.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `NullableClass` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of NullableClass given an JSON string + * + * @param jsonString JSON string + * @return An instance of NullableClass + * @throws IOException if the JSON string is invalid with respect to NullableClass + */ + public static NullableClass fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NullableClass.class); + } + + /** + * Convert an instance of NullableClass to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableShape.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableShape.java index f2946ec60ecf..c5bb74f006ad 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableShape.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NullableShape.java @@ -105,10 +105,13 @@ public NullableShape read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize Quadrilateral try { - deserialized = adapterQuadrilateral.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Quadrilateral.validateJsonObject(jsonObject); + actualAdapter = adapterQuadrilateral; match++; log.log(Level.FINER, "Input data matches schema 'Quadrilateral'"); } catch (Exception e) { @@ -118,7 +121,9 @@ public NullableShape read(JsonReader in) throws IOException { // deserialize Triangle try { - deserialized = adapterTriangle.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Triangle.validateJsonObject(jsonObject); + actualAdapter = adapterTriangle; match++; log.log(Level.FINER, "Input data matches schema 'Triangle'"); } catch (Exception e) { @@ -128,7 +133,7 @@ public NullableShape read(JsonReader in) throws IOException { if (match == 1) { NullableShape ret = new NullableShape(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -228,5 +233,53 @@ public Triangle getTriangle() throws ClassCastException { return (Triangle)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NullableShape + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with Quadrilateral + try { + Quadrilateral.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Triangle + try { + Triangle.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for NullableShape with oneOf schemas: Quadrilateral, Triangle. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of NullableShape given an JSON string + * + * @param jsonString JSON string + * @return An instance of NullableShape + * @throws IOException if the JSON string is invalid with respect to NullableShape + */ + public static NullableShape fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NullableShape.class); + } + + /** + * Convert an instance of NullableShape to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NumberOnly.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NumberOnly.java index 7dc78d63d078..180a6db89aac 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NumberOnly.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/NumberOnly.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * NumberOnly */ @@ -113,6 +116,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NumberOnly + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (NumberOnly.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in NumberOnly is not found in the empty JSON string", NumberOnly.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!NumberOnly.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,19 +172,33 @@ public void write(JsonWriter out, NumberOnly value) throws IOException { @Override public NumberOnly read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!NumberOnly.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `NumberOnly` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of NumberOnly given an JSON string + * + * @param jsonString JSON string + * @return An instance of NumberOnly + * @throws IOException if the JSON string is invalid with respect to NumberOnly + */ + public static NumberOnly fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NumberOnly.class); + } + + /** + * Convert an instance of NumberOnly to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java index 654a4415afb5..773a079fe4fa 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java @@ -30,6 +30,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -44,6 +45,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ObjectWithDeprecatedFields */ @@ -217,6 +220,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -232,6 +236,33 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ObjectWithDeprecatedFields + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ObjectWithDeprecatedFields.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ObjectWithDeprecatedFields is not found in the empty JSON string", ObjectWithDeprecatedFields.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ObjectWithDeprecatedFields.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ObjectWithDeprecatedFields` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `deprecatedRef` + if (jsonObj.getAsJsonObject("deprecatedRef") != null) { + DeprecatedObject.validateJsonObject(jsonObj.getAsJsonObject("deprecatedRef")); + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -252,19 +283,33 @@ public void write(JsonWriter out, ObjectWithDeprecatedFields value) throws IOExc @Override public ObjectWithDeprecatedFields read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ObjectWithDeprecatedFields.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ObjectWithDeprecatedFields` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ObjectWithDeprecatedFields given an JSON string + * + * @param jsonString JSON string + * @return An instance of ObjectWithDeprecatedFields + * @throws IOException if the JSON string is invalid with respect to ObjectWithDeprecatedFields + */ + public static ObjectWithDeprecatedFields fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ObjectWithDeprecatedFields.class); + } + + /** + * Convert an instance of ObjectWithDeprecatedFields to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Order.java index 531e45320f08..82d8a256c0b1 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Order.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Order */ @@ -307,6 +310,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -324,6 +328,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Order + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Order.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Order is not found in the empty JSON string", Order.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Order.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Order` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -344,19 +371,33 @@ public void write(JsonWriter out, Order value) throws IOException { @Override public Order read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Order.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Order` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Order given an JSON string + * + * @param jsonString JSON string + * @return An instance of Order + * @throws IOException if the JSON string is invalid with respect to Order + */ + public static Order fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Order.class); + } + + /** + * Convert an instance of Order to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/OuterComposite.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/OuterComposite.java index c0f8c964ff91..e86d5bc5ff5e 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/OuterComposite.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/OuterComposite.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * OuterComposite */ @@ -171,6 +174,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -185,6 +189,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to OuterComposite + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (OuterComposite.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in OuterComposite is not found in the empty JSON string", OuterComposite.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!OuterComposite.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OuterComposite` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -205,19 +232,33 @@ public void write(JsonWriter out, OuterComposite value) throws IOException { @Override public OuterComposite read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!OuterComposite.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `OuterComposite` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of OuterComposite given an JSON string + * + * @param jsonString JSON string + * @return An instance of OuterComposite + * @throws IOException if the JSON string is invalid with respect to OuterComposite + */ + public static OuterComposite fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OuterComposite.class); + } + + /** + * Convert an instance of OuterComposite to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ParentPet.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ParentPet.java index f96071be437a..392debad35f2 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ParentPet.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ParentPet.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ParentPet */ @@ -86,6 +89,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -99,6 +103,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("pet_type"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ParentPet + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ParentPet.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ParentPet is not found in the empty JSON string", ParentPet.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ParentPet.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ParentPet` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ParentPet.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -119,26 +153,33 @@ public void write(JsonWriter out, ParentPet value) throws IOException { @Override public ParentPet read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ParentPet.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ParentPet` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ParentPet.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ParentPet given an JSON string + * + * @param jsonString JSON string + * @return An instance of ParentPet + * @throws IOException if the JSON string is invalid with respect to ParentPet + */ + public static ParentPet fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ParentPet.class); + } + + /** + * Convert an instance of ParentPet to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pet.java index 5d0065de40dd..5d2d5688cb3c 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pet.java @@ -30,6 +30,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -44,6 +45,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Pet */ @@ -323,6 +326,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -342,6 +346,47 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("photoUrls"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Pet + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Pet.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Pet is not found in the empty JSON string", Pet.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Pet.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Pet.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the optional field `category` + if (jsonObj.getAsJsonObject("category") != null) { + Category.validateJsonObject(jsonObj.getAsJsonObject("category")); + } + JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); + // validate the optional field `tags` (array) + if (jsonArraytags != null) { + for (int i = 0; i < jsonArraytags.size(); i++) { + Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject()); + }; + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -362,26 +407,33 @@ public void write(JsonWriter out, Pet value) throws IOException { @Override public Pet read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Pet.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Pet` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Pet.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Pet given an JSON string + * + * @param jsonString JSON string + * @return An instance of Pet + * @throws IOException if the JSON string is invalid with respect to Pet + */ + public static Pet fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Pet.class); + } + + /** + * Convert an instance of Pet to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java new file mode 100644 index 000000000000..c7c647842d31 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java @@ -0,0 +1,437 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * PetWithRequiredTags + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class PetWithRequiredTags { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private Long id; + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + private Category category; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls"; + @SerializedName(SERIALIZED_NAME_PHOTO_URLS) + private List photoUrls = new ArrayList(); + + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) + private List tags = new ArrayList(); + + /** + * 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 value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + 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(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public PetWithRequiredTags() { + } + + public PetWithRequiredTags id(Long id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Long getId() { + return id; + } + + + public void setId(Long id) { + this.id = id; + } + + + public PetWithRequiredTags category(Category category) { + + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Category getCategory() { + return category; + } + + + public void setCategory(Category category) { + this.category = category; + } + + + public PetWithRequiredTags name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "doggie", required = true, value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public PetWithRequiredTags photoUrls(List photoUrls) { + + this.photoUrls = photoUrls; + return this; + } + + public PetWithRequiredTags addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public List getPhotoUrls() { + return photoUrls; + } + + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + public PetWithRequiredTags tags(List tags) { + + this.tags = tags; + return this; + } + + public PetWithRequiredTags addTagsItem(Tag tagsItem) { + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public List getTags() { + return tags; + } + + + public void setTags(List tags) { + this.tags = tags; + } + + + public PetWithRequiredTags status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "pet status in the store") + + public StatusEnum getStatus() { + return status; + } + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithRequiredTags petWithRequiredTags = (PetWithRequiredTags) o; + return Objects.equals(this.id, petWithRequiredTags.id) && + Objects.equals(this.category, petWithRequiredTags.category) && + Objects.equals(this.name, petWithRequiredTags.name) && + Objects.equals(this.photoUrls, petWithRequiredTags.photoUrls) && + Objects.equals(this.tags, petWithRequiredTags.tags) && + Objects.equals(this.status, petWithRequiredTags.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 PetWithRequiredTags {\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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("category"); + openapiFields.add("name"); + openapiFields.add("photoUrls"); + openapiFields.add("tags"); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("photoUrls"); + openapiRequiredFields.add("tags"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PetWithRequiredTags + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (PetWithRequiredTags.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in PetWithRequiredTags is not found in the empty JSON string", PetWithRequiredTags.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PetWithRequiredTags.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PetWithRequiredTags` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PetWithRequiredTags.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the optional field `category` + if (jsonObj.getAsJsonObject("category") != null) { + Category.validateJsonObject(jsonObj.getAsJsonObject("category")); + } + JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); + // validate the optional field `tags` (array) + if (jsonArraytags != null) { + for (int i = 0; i < jsonArraytags.size(); i++) { + Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject()); + }; + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PetWithRequiredTags.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PetWithRequiredTags' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PetWithRequiredTags.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PetWithRequiredTags value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PetWithRequiredTags read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PetWithRequiredTags given an JSON string + * + * @param jsonString JSON string + * @return An instance of PetWithRequiredTags + * @throws IOException if the JSON string is invalid with respect to PetWithRequiredTags + */ + public static PetWithRequiredTags fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PetWithRequiredTags.class); + } + + /** + * Convert an instance of PetWithRequiredTags to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pig.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pig.java index 54982ba3f8ef..7523f9b91672 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pig.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Pig.java @@ -105,10 +105,13 @@ public Pig read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize BasquePig try { - deserialized = adapterBasquePig.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + BasquePig.validateJsonObject(jsonObject); + actualAdapter = adapterBasquePig; match++; log.log(Level.FINER, "Input data matches schema 'BasquePig'"); } catch (Exception e) { @@ -118,7 +121,9 @@ public Pig read(JsonReader in) throws IOException { // deserialize DanishPig try { - deserialized = adapterDanishPig.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + DanishPig.validateJsonObject(jsonObject); + actualAdapter = adapterDanishPig; match++; log.log(Level.FINER, "Input data matches schema 'DanishPig'"); } catch (Exception e) { @@ -128,7 +133,7 @@ public Pig read(JsonReader in) throws IOException { if (match == 1) { Pig ret = new Pig(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -223,5 +228,53 @@ public DanishPig getDanishPig() throws ClassCastException { return (DanishPig)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Pig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with BasquePig + try { + BasquePig.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with DanishPig + try { + DanishPig.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for Pig with oneOf schemas: BasquePig, DanishPig. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of Pig given an JSON string + * + * @param jsonString JSON string + * @return An instance of Pig + * @throws IOException if the JSON string is invalid with respect to Pig + */ + public static Pig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Pig.class); + } + + /** + * Convert an instance of Pig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Quadrilateral.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Quadrilateral.java index aad102d30574..f6565d05cdf9 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Quadrilateral.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Quadrilateral.java @@ -105,10 +105,13 @@ public Quadrilateral read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize ComplexQuadrilateral try { - deserialized = adapterComplexQuadrilateral.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + ComplexQuadrilateral.validateJsonObject(jsonObject); + actualAdapter = adapterComplexQuadrilateral; match++; log.log(Level.FINER, "Input data matches schema 'ComplexQuadrilateral'"); } catch (Exception e) { @@ -118,7 +121,9 @@ public Quadrilateral read(JsonReader in) throws IOException { // deserialize SimpleQuadrilateral try { - deserialized = adapterSimpleQuadrilateral.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + SimpleQuadrilateral.validateJsonObject(jsonObject); + actualAdapter = adapterSimpleQuadrilateral; match++; log.log(Level.FINER, "Input data matches schema 'SimpleQuadrilateral'"); } catch (Exception e) { @@ -128,7 +133,7 @@ public Quadrilateral read(JsonReader in) throws IOException { if (match == 1) { Quadrilateral ret = new Quadrilateral(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -223,5 +228,53 @@ public SimpleQuadrilateral getSimpleQuadrilateral() throws ClassCastException { return (SimpleQuadrilateral)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Quadrilateral + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with ComplexQuadrilateral + try { + ComplexQuadrilateral.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with SimpleQuadrilateral + try { + SimpleQuadrilateral.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for Quadrilateral with oneOf schemas: ComplexQuadrilateral, SimpleQuadrilateral. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of Quadrilateral given an JSON string + * + * @param jsonString JSON string + * @return An instance of Quadrilateral + * @throws IOException if the JSON string is invalid with respect to Quadrilateral + */ + public static Quadrilateral fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Quadrilateral.class); + } + + /** + * Convert an instance of Quadrilateral to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/QuadrilateralInterface.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/QuadrilateralInterface.java index e6fc7e3d3484..2c5e5ff914d9 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/QuadrilateralInterface.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/QuadrilateralInterface.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * QuadrilateralInterface */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("quadrilateralType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to QuadrilateralInterface + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (QuadrilateralInterface.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in QuadrilateralInterface is not found in the empty JSON string", QuadrilateralInterface.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!QuadrilateralInterface.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `QuadrilateralInterface` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : QuadrilateralInterface.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,26 +179,33 @@ public void write(JsonWriter out, QuadrilateralInterface value) throws IOExcepti @Override public QuadrilateralInterface read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!QuadrilateralInterface.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `QuadrilateralInterface` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : QuadrilateralInterface.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of QuadrilateralInterface given an JSON string + * + * @param jsonString JSON string + * @return An instance of QuadrilateralInterface + * @throws IOException if the JSON string is invalid with respect to QuadrilateralInterface + */ + public static QuadrilateralInterface fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, QuadrilateralInterface.class); + } + + /** + * Convert an instance of QuadrilateralInterface to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java index d842df280faf..14b28a610665 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ReadOnlyFirst */ @@ -140,6 +143,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -153,6 +157,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ReadOnlyFirst + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ReadOnlyFirst.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ReadOnlyFirst is not found in the empty JSON string", ReadOnlyFirst.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ReadOnlyFirst.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ReadOnlyFirst` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -173,19 +200,33 @@ public void write(JsonWriter out, ReadOnlyFirst value) throws IOException { @Override public ReadOnlyFirst read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ReadOnlyFirst.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ReadOnlyFirst` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ReadOnlyFirst given an JSON string + * + * @param jsonString JSON string + * @return An instance of ReadOnlyFirst + * @throws IOException if the JSON string is invalid with respect to ReadOnlyFirst + */ + public static ReadOnlyFirst fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ReadOnlyFirst.class); + } + + /** + * Convert an instance of ReadOnlyFirst to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ScaleneTriangle.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ScaleneTriangle.java index f7dec655276a..0c0de34386fc 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ScaleneTriangle.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ScaleneTriangle.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ScaleneTriangle */ @@ -143,6 +146,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -158,6 +162,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("triangleType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ScaleneTriangle + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ScaleneTriangle.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ScaleneTriangle is not found in the empty JSON string", ScaleneTriangle.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ScaleneTriangle.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ScaleneTriangle` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ScaleneTriangle.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -178,26 +212,33 @@ public void write(JsonWriter out, ScaleneTriangle value) throws IOException { @Override public ScaleneTriangle read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ScaleneTriangle.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ScaleneTriangle` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ScaleneTriangle.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ScaleneTriangle given an JSON string + * + * @param jsonString JSON string + * @return An instance of ScaleneTriangle + * @throws IOException if the JSON string is invalid with respect to ScaleneTriangle + */ + public static ScaleneTriangle fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ScaleneTriangle.class); + } + + /** + * Convert an instance of ScaleneTriangle to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Shape.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Shape.java index 23b4c43b002c..dc6334a97822 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Shape.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Shape.java @@ -105,10 +105,13 @@ public Shape read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize Quadrilateral try { - deserialized = adapterQuadrilateral.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Quadrilateral.validateJsonObject(jsonObject); + actualAdapter = adapterQuadrilateral; match++; log.log(Level.FINER, "Input data matches schema 'Quadrilateral'"); } catch (Exception e) { @@ -118,7 +121,9 @@ public Shape read(JsonReader in) throws IOException { // deserialize Triangle try { - deserialized = adapterTriangle.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Triangle.validateJsonObject(jsonObject); + actualAdapter = adapterTriangle; match++; log.log(Level.FINER, "Input data matches schema 'Triangle'"); } catch (Exception e) { @@ -128,7 +133,7 @@ public Shape read(JsonReader in) throws IOException { if (match == 1) { Shape ret = new Shape(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -223,5 +228,53 @@ public Triangle getTriangle() throws ClassCastException { return (Triangle)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Shape + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with Quadrilateral + try { + Quadrilateral.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Triangle + try { + Triangle.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for Shape with oneOf schemas: Quadrilateral, Triangle. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of Shape given an JSON string + * + * @param jsonString JSON string + * @return An instance of Shape + * @throws IOException if the JSON string is invalid with respect to Shape + */ + public static Shape fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Shape.class); + } + + /** + * Convert an instance of Shape to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeInterface.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeInterface.java index 628c2f7af2b2..3aa6fadf9ef2 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeInterface.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeInterface.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * ShapeInterface */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("shapeType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ShapeInterface + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (ShapeInterface.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in ShapeInterface is not found in the empty JSON string", ShapeInterface.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ShapeInterface.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ShapeInterface` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ShapeInterface.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,26 +179,33 @@ public void write(JsonWriter out, ShapeInterface value) throws IOException { @Override public ShapeInterface read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!ShapeInterface.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `ShapeInterface` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ShapeInterface.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of ShapeInterface given an JSON string + * + * @param jsonString JSON string + * @return An instance of ShapeInterface + * @throws IOException if the JSON string is invalid with respect to ShapeInterface + */ + public static ShapeInterface fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ShapeInterface.class); + } + + /** + * Convert an instance of ShapeInterface to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeOrNull.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeOrNull.java index 871b88812982..b48a29b873b7 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeOrNull.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/ShapeOrNull.java @@ -105,10 +105,13 @@ public ShapeOrNull read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize Quadrilateral try { - deserialized = adapterQuadrilateral.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Quadrilateral.validateJsonObject(jsonObject); + actualAdapter = adapterQuadrilateral; match++; log.log(Level.FINER, "Input data matches schema 'Quadrilateral'"); } catch (Exception e) { @@ -118,7 +121,9 @@ public ShapeOrNull read(JsonReader in) throws IOException { // deserialize Triangle try { - deserialized = adapterTriangle.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + Triangle.validateJsonObject(jsonObject); + actualAdapter = adapterTriangle; match++; log.log(Level.FINER, "Input data matches schema 'Triangle'"); } catch (Exception e) { @@ -128,7 +133,7 @@ public ShapeOrNull read(JsonReader in) throws IOException { if (match == 1) { ShapeOrNull ret = new ShapeOrNull(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -228,5 +233,53 @@ public Triangle getTriangle() throws ClassCastException { return (Triangle)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ShapeOrNull + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with Quadrilateral + try { + Quadrilateral.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with Triangle + try { + Triangle.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for ShapeOrNull with oneOf schemas: Quadrilateral, Triangle. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of ShapeOrNull given an JSON string + * + * @param jsonString JSON string + * @return An instance of ShapeOrNull + * @throws IOException if the JSON string is invalid with respect to ShapeOrNull + */ + public static ShapeOrNull fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ShapeOrNull.class); + } + + /** + * Convert an instance of ShapeOrNull to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SimpleQuadrilateral.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SimpleQuadrilateral.java index 064c5f0996ce..9a87c62f5965 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SimpleQuadrilateral.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SimpleQuadrilateral.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * SimpleQuadrilateral */ @@ -143,6 +146,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -158,6 +162,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("quadrilateralType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SimpleQuadrilateral + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (SimpleQuadrilateral.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in SimpleQuadrilateral is not found in the empty JSON string", SimpleQuadrilateral.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SimpleQuadrilateral.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SimpleQuadrilateral` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SimpleQuadrilateral.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -178,26 +212,33 @@ public void write(JsonWriter out, SimpleQuadrilateral value) throws IOException @Override public SimpleQuadrilateral read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!SimpleQuadrilateral.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `SimpleQuadrilateral` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : SimpleQuadrilateral.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of SimpleQuadrilateral given an JSON string + * + * @param jsonString JSON string + * @return An instance of SimpleQuadrilateral + * @throws IOException if the JSON string is invalid with respect to SimpleQuadrilateral + */ + public static SimpleQuadrilateral fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SimpleQuadrilateral.class); + } + + /** + * Convert an instance of SimpleQuadrilateral to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SpecialModelName.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SpecialModelName.java index dfdbc850f430..9b26d894f051 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/SpecialModelName.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * SpecialModelName */ @@ -141,6 +144,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -154,6 +158,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SpecialModelName + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (SpecialModelName.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialModelName is not found in the empty JSON string", SpecialModelName.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SpecialModelName.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialModelName` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -174,19 +201,33 @@ public void write(JsonWriter out, SpecialModelName value) throws IOException { @Override public SpecialModelName read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!SpecialModelName.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `SpecialModelName` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of SpecialModelName given an JSON string + * + * @param jsonString JSON string + * @return An instance of SpecialModelName + * @throws IOException if the JSON string is invalid with respect to SpecialModelName + */ + public static SpecialModelName fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SpecialModelName.class); + } + + /** + * Convert an instance of SpecialModelName to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Tag.java index 78ea45ac8617..0aae4c29af96 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Tag.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Tag */ @@ -141,6 +144,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -154,6 +158,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Tag + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Tag.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Tag is not found in the empty JSON string", Tag.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Tag.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -174,19 +201,33 @@ public void write(JsonWriter out, Tag value) throws IOException { @Override public Tag read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Tag.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Tag` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Tag given an JSON string + * + * @param jsonString JSON string + * @return An instance of Tag + * @throws IOException if the JSON string is invalid with respect to Tag + */ + public static Tag fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Tag.class); + } + + /** + * Convert an instance of Tag to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Triangle.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Triangle.java index 9311228bf044..0bbf11f06445 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Triangle.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Triangle.java @@ -114,10 +114,13 @@ public Triangle read(JsonReader in) throws IOException { JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); int match = 0; + TypeAdapter actualAdapter = elementAdapter; // deserialize EquilateralTriangle try { - deserialized = adapterEquilateralTriangle.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + EquilateralTriangle.validateJsonObject(jsonObject); + actualAdapter = adapterEquilateralTriangle; match++; log.log(Level.FINER, "Input data matches schema 'EquilateralTriangle'"); } catch (Exception e) { @@ -127,7 +130,9 @@ public Triangle read(JsonReader in) throws IOException { // deserialize IsoscelesTriangle try { - deserialized = adapterIsoscelesTriangle.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + IsoscelesTriangle.validateJsonObject(jsonObject); + actualAdapter = adapterIsoscelesTriangle; match++; log.log(Level.FINER, "Input data matches schema 'IsoscelesTriangle'"); } catch (Exception e) { @@ -137,7 +142,9 @@ public Triangle read(JsonReader in) throws IOException { // deserialize ScaleneTriangle try { - deserialized = adapterScaleneTriangle.fromJsonTree(jsonObject); + // validate the JSON object to see if any excpetion is thrown + ScaleneTriangle.validateJsonObject(jsonObject); + actualAdapter = adapterScaleneTriangle; match++; log.log(Level.FINER, "Input data matches schema 'ScaleneTriangle'"); } catch (Exception e) { @@ -147,7 +154,7 @@ public Triangle read(JsonReader in) throws IOException { if (match == 1) { Triangle ret = new Triangle(); - ret.setActualInstance(deserialized); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); return ret; } @@ -265,5 +272,60 @@ public ScaleneTriangle getScaleneTriangle() throws ClassCastException { return (ScaleneTriangle)super.getActualInstance(); } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Triangle + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + // validate the json string with EquilateralTriangle + try { + EquilateralTriangle.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with IsoscelesTriangle + try { + IsoscelesTriangle.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with ScaleneTriangle + try { + ScaleneTriangle.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for Triangle with oneOf schemas: EquilateralTriangle, IsoscelesTriangle, ScaleneTriangle. %d class(es) match the result, expected 1. JSON: %s", validCount, jsonObj.toString())); + } + } + + /** + * Create an instance of Triangle given an JSON string + * + * @param jsonString JSON string + * @return An instance of Triangle + * @throws IOException if the JSON string is invalid with respect to Triangle + */ + public static Triangle fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Triangle.class); + } + + /** + * Convert an instance of Triangle to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/TriangleInterface.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/TriangleInterface.java index a03456d2a064..24615e15889b 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/TriangleInterface.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/TriangleInterface.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * TriangleInterface */ @@ -112,6 +115,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -125,6 +129,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("triangleType"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TriangleInterface + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (TriangleInterface.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in TriangleInterface is not found in the empty JSON string", TriangleInterface.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!TriangleInterface.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TriangleInterface` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TriangleInterface.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -145,26 +179,33 @@ public void write(JsonWriter out, TriangleInterface value) throws IOException { @Override public TriangleInterface read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!TriangleInterface.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `TriangleInterface` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : TriangleInterface.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of TriangleInterface given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriangleInterface + * @throws IOException if the JSON string is invalid with respect to TriangleInterface + */ + public static TriangleInterface fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriangleInterface.class); + } + + /** + * Convert an instance of TriangleInterface to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/User.java index 4f60e1ecd730..d1b54e47fe4e 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/User.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -41,6 +42,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * User */ @@ -443,6 +446,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -466,6 +470,29 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to User + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (User.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in User is not found in the empty JSON string", User.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!User.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -486,19 +513,33 @@ public void write(JsonWriter out, User value) throws IOException { @Override public User read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!User.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `User` properties"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of User given an JSON string + * + * @param jsonString JSON string + * @return An instance of User + * @throws IOException if the JSON string is invalid with respect to User + */ + public static User fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, User.class); + } + + /** + * Convert an instance of User to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Whale.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Whale.java index c84faf2790bd..b7d11108b28f 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Whale.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Whale.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -40,6 +41,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Whale */ @@ -170,6 +173,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -185,6 +189,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("className"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Whale + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Whale.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Whale is not found in the empty JSON string", Whale.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Whale.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Whale` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Whale.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -205,26 +239,33 @@ public void write(JsonWriter out, Whale value) throws IOException { @Override public Whale read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Whale.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Whale` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Whale.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Whale given an JSON string + * + * @param jsonString JSON string + * @return An instance of Whale + * @throws IOException if the JSON string is invalid with respect to Whale + */ + public static Whale fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Whale.class); + } + + /** + * Convert an instance of Whale to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Zebra.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Zebra.java index 7821c21caccf..260cde0f44b9 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Zebra.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/model/Zebra.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -42,6 +43,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.openapitools.client.JSON; + /** * Zebra */ @@ -194,6 +197,7 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + public static HashSet openapiFields; public static HashSet openapiRequiredFields; @@ -208,6 +212,36 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("className"); } + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Zebra + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (Zebra.openapiRequiredFields.isEmpty()) { + return; + } else { // has reuqired fields + throw new IllegalArgumentException(String.format("The required field(s) %s in Zebra is not found in the empty JSON string", Zebra.openapiRequiredFields.toString())); + } + } + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Zebra.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Zebra` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Zebra.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override @@ -228,26 +262,33 @@ public void write(JsonWriter out, Zebra value) throws IOException { @Override public Zebra read(JsonReader in) throws IOException { - JsonObject obj = elementAdapter.read(in).getAsJsonObject(); - Set> entries = obj.entrySet();//will return members of your object - // check to see if the JSON string contains additional fields - for (Entry entry: entries) { - if (!Zebra.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException("The field `" + entry.getKey() + "` in the JSON string is not defined in the `Zebra` properties"); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Zebra.openapiRequiredFields) { - if (obj.get(requiredField) == null) { - throw new IllegalArgumentException("The required field `" + requiredField + "` is not found in the JSON string"); - } - } - - return thisAdapter.fromJsonTree(obj); + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); } }.nullSafe(); } } + + /** + * Create an instance of Zebra given an JSON string + * + * @param jsonString JSON string + * @return An instance of Zebra + * @throws IOException if the JSON string is invalid with respect to Zebra + */ + public static Zebra fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Zebra.class); + } + + /** + * Convert an instance of Zebra to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/JSONTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/JSONTest.java index 6b631a5a9805..9d56087899b3 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/JSONTest.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/JSONTest.java @@ -245,10 +245,46 @@ public void testCustomDeserializer() { assertEquals(t2.getId(), null); // with all required fields - String json3 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"]}"; // missing photoUrls (required field) + String json3 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"]}"; Pet t3 = gson.fromJson(json3, Pet.class); assertEquals(t3.getName(), "pet test 1"); assertEquals(t3.getId(), Long.valueOf(5847)); + + // with all required fields and tags (optional) + String json4 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"],\"tags\":[{\"id\":\"tag 123\"}]}"; + Pet t4 = gson.fromJson(json3, Pet.class); + assertEquals(t4.getName(), "pet test 1"); + assertEquals(t4.getId(), Long.valueOf(5847)); + + // test Tag + String json5 = "{\"unknown_field\": 543, \"id\":\"tag 123\"}"; + Exception exception5 = assertThrows(java.lang.IllegalArgumentException.class, () -> { + Tag t5 = gson.fromJson(json5, Tag.class); + }); + assertTrue(exception5.getMessage().contains("The field `unknown_field` in the JSON string is not defined in the `Tag` properties. JSON: {\"unknown_field\":543,\"id\":\"tag 123\"}")); + + // test Pet with invalid tags + String json6 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"],\"tags\":[{\"unknown_field\": 543, \"id\":\"tag 123\"}]}"; + Exception exception6 = assertThrows(java.lang.IllegalArgumentException.class, () -> { + Pet t6 = gson.fromJson(json6, Pet.class); + }); + assertTrue(exception6.getMessage().contains("The field `unknown_field` in the JSON string is not defined in the `Tag` properties. JSON: {\"unknown_field\":543,\"id\":\"tag 123\"}")); + + // test Pet with invalid tags (required) + String json7 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"],\"tags\":[{\"unknown_field\": 543, \"id\":\"tag 123\"}]}"; + Exception exception7 = assertThrows(java.lang.IllegalArgumentException.class, () -> { + PetWithRequiredTags t7 = gson.fromJson(json7, PetWithRequiredTags.class); + }); + assertTrue(exception7.getMessage().contains("The field `unknown_field` in the JSON string is not defined in the `Tag` properties. JSON: {\"unknown_field\":543,\"id\":\"tag 123\"}")); + + // test Pet with invalid tags (missing reqired) + String json8 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"]}"; + Exception exception8 = assertThrows(java.lang.IllegalArgumentException.class, () -> { + PetWithRequiredTags t8 = gson.fromJson(json8, PetWithRequiredTags.class); + }); + assertTrue(exception8.getMessage().contains("The required field `tags` is not found in the JSON string: {\"id\":5847,\"name\":\"pet test 1\",\"photoUrls\":[\"https://a.com\",\"https://b.com\"]}")); + + } /** Model tests for Pet */ @@ -306,7 +342,9 @@ public void testAnyOfSchemaWithoutDiscriminator() throws Exception { assertEquals(inst.getCultivar(), "golden delicious"); assertEquals(inst.getOrigin(), "japan"); assertEquals(json.getGson().toJson(inst), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}"); + assertEquals(inst.toJson(), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}"); assertEquals(json.getGson().toJson(o), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}"); + assertEquals(o.toJson(), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}"); String str2 = "{ \"origin_typo\": \"japan\" }"; // no match @@ -348,18 +386,32 @@ public void testOneOfSchemaWithoutDiscriminator() throws Exception { assertEquals(inst.getCultivar(), "golden delicious"); assertEquals(inst.getMealy(), false); assertEquals(json.getGson().toJson(inst), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); + assertEquals(inst.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); assertEquals(json.getGson().toJson(o), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); + assertEquals(o.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); AppleReq inst2 = o.getAppleReq(); assertEquals(inst2.getCultivar(), "golden delicious"); assertEquals(inst2.getMealy(), false); assertEquals(json.getGson().toJson(inst2), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); + assertEquals(inst2.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); + + // test fromJson + FruitReq o3 = FruitReq.fromJson(str); + assertTrue(o3.getActualInstance() instanceof AppleReq); + AppleReq inst3 = (AppleReq) o3.getActualInstance(); + assertEquals(inst3.getCultivar(), "golden delicious"); + assertEquals(inst3.getMealy(), false); + assertEquals(json.getGson().toJson(inst3), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); + assertEquals(inst3.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); + assertEquals(o3.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}"); } { // test to ensure the oneOf object can be serialized to "null" correctly FruitReq o = new FruitReq(); assertEquals(o.getActualInstance(), null); assertEquals(json.getGson().toJson(o), "null"); + assertEquals(o.toJson(), "null"); assertEquals(json.getGson().toJson(null), "null"); } { diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/api/FakeApiTest.java index 54eb3e8e090f..471887d2611e 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/api/FakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -17,7 +17,6 @@ import java.math.BigDecimal; import org.openapitools.client.model.Client; import java.io.File; -import org.openapitools.client.model.FileSchemaTestClass; import org.openapitools.client.model.HealthCheckResult; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; @@ -129,21 +128,6 @@ public void getArrayOfEnumsTest() throws ApiException { // TODO: test validations } - /** - * - * - * For this test, the body for this request much reference a schema named `File`. - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void testBodyWithFileSchemaTest() throws ApiException { - FileSchemaTestClass fileSchemaTestClass = null; - api.testBodyWithFileSchema(fileSchemaTestClass); - // TODO: test validations - } - /** * * diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/PetWithRequiredTagsTest.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/PetWithRequiredTagsTest.java new file mode 100644 index 000000000000..4d78953915e2 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/test/java/org/openapitools/client/model/PetWithRequiredTagsTest.java @@ -0,0 +1,95 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for PetWithRequiredTags + */ +public class PetWithRequiredTagsTest { + private final PetWithRequiredTags model = new PetWithRequiredTags(); + + /** + * Model tests for PetWithRequiredTags + */ + @Test + public void testPetWithRequiredTags() { + // TODO: test PetWithRequiredTags + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'category' + */ + @Test + public void categoryTest() { + // TODO: test category + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'photoUrls' + */ + @Test + public void photoUrlsTest() { + // TODO: test photoUrls + } + + /** + * Test the property 'tags' + */ + @Test + public void tagsTest() { + // TODO: test tags + } + + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } + +} diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/ModelFile.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/ModelFile.md new file mode 100644 index 000000000000..37ad0cfd8e93 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/ModelFile.md @@ -0,0 +1,18 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + +## Implemented Interfaces + +* Parcelable + + diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/ModelList.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/ModelList.md new file mode 100644 index 000000000000..232bbf2e0a8c --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/ModelList.md @@ -0,0 +1,17 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + +## Implemented Interfaces + +* Parcelable + + diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..99e3a6b454df --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,124 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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 android.os.Parcelable; +import android.os.Parcel; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile implements Parcelable { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public void writeToParcel(Parcel out, int flags) { + out.writeValue(sourceURI); + } + + ModelFile(Parcel in) { + sourceURI = (String)in.readValue(null); + } + + public int describeContents() { + return 0; + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public ModelFile createFromParcel(Parcel in) { + return new ModelFile(in); + } + public ModelFile[] newArray(int size) { + return new ModelFile[size]; + } + }; +} + diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..3c03ba17da0a --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,123 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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 android.os.Parcelable; +import android.os.Parcel; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList implements Parcelable { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public void writeToParcel(Parcel out, int flags) { + out.writeValue(_123list); + } + + ModelList(Parcel in) { + _123list = (String)in.readValue(null); + } + + public int describeContents() { + return 0; + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public ModelList createFromParcel(Parcel in) { + return new ModelList(in); + } + public ModelList[] newArray(int size) { + return new ModelList[size]; + } + }; +} + diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/okhttp-gson/docs/ModelFile.md b/samples/client/petstore/java/okhttp-gson/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/ModelList.md b/samples/client/petstore/java/okhttp-gson/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..111a748ceff8 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,101 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2ba46fefd4fe --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/rest-assured-jackson/docs/ModelFile.md b/samples/client/petstore/java/rest-assured-jackson/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured-jackson/docs/ModelList.md b/samples/client/petstore/java/rest-assured-jackson/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..6197afe89186 --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,112 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import javax.validation.constraints.*; +import javax.validation.Valid; +import org.hibernate.validator.constraints.*; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..b68373d3d8a5 --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,111 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import javax.validation.constraints.*; +import javax.validation.Valid; +import org.hibernate.validator.constraints.*; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/rest-assured-jackson/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/rest-assured-jackson/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/rest-assured-jackson/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/rest-assured-jackson/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/rest-assured/docs/ModelFile.md b/samples/client/petstore/java/rest-assured/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/docs/ModelList.md b/samples/client/petstore/java/rest-assured/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/rest-assured/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..44f900da9832 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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 javax.validation.constraints.*; +import javax.validation.Valid; +import org.hibernate.validator.constraints.*; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(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/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..d3a2c8150740 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,103 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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 javax.validation.constraints.*; +import javax.validation.Valid; +import org.hibernate.validator.constraints.*; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(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/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/rest-assured/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/rest-assured/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/rest-assured/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/rest-assured/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/resteasy/docs/ModelFile.md b/samples/client/petstore/java/resteasy/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/resteasy/docs/ModelList.md b/samples/client/petstore/java/resteasy/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/ModelFile.md b/samples/client/petstore/java/resttemplate-withXml/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/ModelList.md b/samples/client/petstore/java/resttemplate-withXml/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..c87bc9199422 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,117 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.dataformat.xml.annotation.*; +import javax.xml.bind.annotation.*; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@XmlRootElement(name = "ModelFile") +@XmlAccessorType(XmlAccessType.FIELD) +@JacksonXmlRootElement(localName = "ModelFile") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + @XmlElement(name = "sourceURI") + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "sourceURI") + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "sourceURI") + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..32aadcded838 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,116 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.dataformat.xml.annotation.*; +import javax.xml.bind.annotation.*; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@XmlRootElement(name = "ModelList") +@XmlAccessorType(XmlAccessType.FIELD) +@JacksonXmlRootElement(localName = "ModelList") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + @XmlElement(name = "123-list") + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "123-list") + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "123-list") + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/resttemplate/docs/ModelFile.md b/samples/client/petstore/java/resttemplate/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/resttemplate/docs/ModelList.md b/samples/client/petstore/java/resttemplate/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/retrofit2-play26/docs/ModelFile.md b/samples/client/petstore/java/retrofit2-play26/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2-play26/docs/ModelList.md b/samples/client/petstore/java/retrofit2-play26/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..42060439bffc --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,111 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import javax.validation.constraints.*; +import javax.validation.Valid; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..6eb2c7833726 --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import javax.validation.constraints.*; +import javax.validation.Valid; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2-play26/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/retrofit2-play26/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/retrofit2-play26/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/retrofit2-play26/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/retrofit2/docs/ModelFile.md b/samples/client/petstore/java/retrofit2/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/retrofit2/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2/docs/ModelList.md b/samples/client/petstore/java/retrofit2/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/retrofit2/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..111a748ceff8 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,101 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2ba46fefd4fe --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/retrofit2/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/retrofit2/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/retrofit2rx2/docs/ModelFile.md b/samples/client/petstore/java/retrofit2rx2/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx2/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2rx2/docs/ModelList.md b/samples/client/petstore/java/retrofit2rx2/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx2/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..111a748ceff8 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,101 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2ba46fefd4fe --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2rx2/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/retrofit2rx2/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx2/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/retrofit2rx2/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/retrofit2rx2/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx2/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/retrofit2rx3/docs/ModelFile.md b/samples/client/petstore/java/retrofit2rx3/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx3/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2rx3/docs/ModelList.md b/samples/client/petstore/java/retrofit2rx3/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx3/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..111a748ceff8 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,101 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String SERIALIZED_NAME_SOURCE_U_R_I = "sourceURI"; + @SerializedName(SERIALIZED_NAME_SOURCE_U_R_I) + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + + public String getSourceURI() { + return sourceURI; + } + + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..2ba46fefd4fe --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.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; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String SERIALIZED_NAME_123LIST = "123-list"; + @SerializedName(SERIALIZED_NAME_123LIST) + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String get123list() { + return _123list; + } + + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit2rx3/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/retrofit2rx3/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..132012d4c387 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx3/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/retrofit2rx3/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/retrofit2rx3/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..d3ed2075e9a4 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx3/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/vertx-no-nullable/docs/ModelFile.md b/samples/client/petstore/java/vertx-no-nullable/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/vertx-no-nullable/docs/ModelList.md b/samples/client/petstore/java/vertx-no-nullable/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/vertx-no-nullable/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/vertx-no-nullable/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/vertx-no-nullable/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/vertx-no-nullable/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/vertx/docs/ModelFile.md b/samples/client/petstore/java/vertx/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/vertx/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/vertx/docs/ModelList.md b/samples/client/petstore/java/vertx/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/vertx/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/client/petstore/java/webclient/docs/ModelFile.md b/samples/client/petstore/java/webclient/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/client/petstore/java/webclient/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/client/petstore/java/webclient/docs/ModelList.md b/samples/client/petstore/java/webclient/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/client/petstore/java/webclient/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..864728364139 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,109 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@JsonTypeName("File") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..82abfba9e39d --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,108 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@JsonTypeName("List") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/ModelFile.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/ModelFile.md new file mode 100644 index 000000000000..1282785e329d --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/ModelFile.md @@ -0,0 +1,14 @@ + + +# ModelFile + +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sourceURI** | **String** | Test capitalization | [optional] + + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/ModelList.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/ModelList.md new file mode 100644 index 000000000000..c838a6a72e4f --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/ModelList.md @@ -0,0 +1,13 @@ + + +# ModelList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123list** | **String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelFile.java new file mode 100644 index 000000000000..0de39ec2ab0a --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelFile.java @@ -0,0 +1,113 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@JsonPropertyOrder({ + ModelFile.JSON_PROPERTY_SOURCE_U_R_I +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelFile { + public static final String JSON_PROPERTY_SOURCE_U_R_I = "sourceURI"; + private String sourceURI; + + public ModelFile() { + } + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Test capitalization") + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSourceURI() { + return sourceURI; + } + + + @JsonProperty(JSON_PROPERTY_SOURCE_U_R_I) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + /** + * Return true if this File object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelList.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelList.java new file mode 100644 index 000000000000..19025e8ec4f3 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/ModelList.java @@ -0,0 +1,112 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * ModelList + */ +@JsonPropertyOrder({ + ModelList.JSON_PROPERTY_123LIST +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelList { + public static final String JSON_PROPERTY_123LIST = "123-list"; + private String _123list; + + public ModelList() { + } + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String get123list() { + return _123list; + } + + + @JsonProperty(JSON_PROPERTY_123LIST) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set123list(String _123list) { + this._123list = _123list; + } + + + /** + * Return true if this List object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelFileTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelFileTest.java new file mode 100644 index 000000000000..5b3fde28d4b4 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelFileTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelFile + */ +public class ModelFileTest { + private final ModelFile model = new ModelFile(); + + /** + * Model tests for ModelFile + */ + @Test + public void testModelFile() { + // TODO: test ModelFile + } + + /** + * Test the property 'sourceURI' + */ + @Test + public void sourceURITest() { + // TODO: test sourceURI + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelListTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelListTest.java new file mode 100644 index 000000000000..36755ee2bd6a --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/ModelListTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for ModelList + */ +public class ModelListTest { + private final ModelList model = new ModelList(); + + /** + * Model tests for ModelList + */ + @Test + public void testModelList() { + // TODO: test ModelList + } + + /** + * Test the property '_123list' + */ + @Test + public void _123listTest() { + // TODO: test _123list + } + +} diff --git a/samples/server/petstore/java-msf4j/src/gen/java/org/openapitools/model/ModelFile.java b/samples/server/petstore/java-msf4j/src/gen/java/org/openapitools/model/ModelFile.java new file mode 100644 index 000000000000..ce611a313c61 --- /dev/null +++ b/samples/server/petstore/java-msf4j/src/gen/java/org/openapitools/model/ModelFile.java @@ -0,0 +1,75 @@ +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Must be named `File` for test. + */ +@ApiModel(description = "Must be named `File` for test.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaMSF4JServerCodegen") +public class ModelFile { + @JsonProperty("sourceURI") + private String sourceURI; + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + @ApiModelProperty(value = "Test capitalization") + public String getSourceURI() { + return sourceURI; + } + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(this.sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-msf4j/src/gen/java/org/openapitools/model/ModelList.java b/samples/server/petstore/java-msf4j/src/gen/java/org/openapitools/model/ModelList.java new file mode 100644 index 000000000000..101752a80d3b --- /dev/null +++ b/samples/server/petstore/java-msf4j/src/gen/java/org/openapitools/model/ModelList.java @@ -0,0 +1,74 @@ +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaMSF4JServerCodegen") +public class ModelList { + @JsonProperty("123-list") + private String _123list; + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + @ApiModelProperty(value = "") + public String get123list() { + return _123list; + } + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(this._123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelFile.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelFile.java new file mode 100644 index 000000000000..16c242ddf5a4 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelFile.java @@ -0,0 +1,75 @@ +package apimodels; + +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * Must be named `File` for test. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +public class ModelFile { + @JsonProperty("sourceURI") + + private String sourceURI; + + public ModelFile sourceURI(String sourceURI) { + this.sourceURI = sourceURI; + return this; + } + + /** + * Test capitalization + * @return sourceURI + **/ + public String getSourceURI() { + return sourceURI; + } + + public void setSourceURI(String sourceURI) { + this.sourceURI = sourceURI; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelFile _file = (ModelFile) o; + return Objects.equals(sourceURI, _file.sourceURI); + } + + @Override + public int hashCode() { + return Objects.hash(sourceURI); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelFile {\n"); + + sb.append(" sourceURI: ").append(toIndentedString(sourceURI)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelList.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelList.java new file mode 100644 index 000000000000..6b6d4a3913ed --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelList.java @@ -0,0 +1,75 @@ +package apimodels; + +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * ModelList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +public class ModelList { + @JsonProperty("123-list") + + private String _123list; + + public ModelList _123list(String _123list) { + this._123list = _123list; + return this; + } + + /** + * Get _123list + * @return _123list + **/ + public String get123list() { + return _123list; + } + + public void set123list(String _123list) { + this._123list = _123list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelList _list = (ModelList) o; + return Objects.equals(_123list, _list._123list); + } + + @Override + public int hashCode() { + return Objects.hash(_123list); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelList {\n"); + + sb.append(" _123list: ").append(toIndentedString(_123list)).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(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} +