diff --git a/Makefile b/Makefile index 426cf72a..c747885a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install-hooks +.PHONY: install-hooks regenerate-samples .git/hooks/pre-commit: venv ${CURDIR}/venv/bin/pre-commit install --install-hooks @@ -6,6 +6,11 @@ install-hooks: .git/hooks/pre-commit @true +regenerate-samples: + ${CURDIR}/gradlew plugin:build + ${CURDIR}/gradlew plugin:publishToMavenLocal + ${CURDIR}/gradlew generateSwagger + venv: virtualenv venv ./venv/bin/pip install pre-commit diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/apis/DefaultApi.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/apis/DefaultApi.kt index c79dbe78..58397a71 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/apis/DefaultApi.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/apis/DefaultApi.kt @@ -6,6 +6,8 @@ package com.yelp.codegen.generatecodesamples.apis +import okhttp3.RequestBody + import com.yelp.codegen.generatecodesamples.models.Pet import io.reactivex.Single import retrofit2.http.GET @@ -13,17 +15,18 @@ import retrofit2.http.Headers @JvmSuppressWildcards interface DefaultApi { - /** - * Find pet by ID - * Returns a single pet - * The endpoint is owned by generatecodesamples service owner - * @param petId ID of pet to return (required) - */ - @Headers( - "X-Operation-ID: getPetById" - ) - @GET("/pet/{petId}") - fun getPetById( - @retrofit2.http.Path("petId") petId: Long - ): Single + /** + * Find pet by ID + * Returns a single pet + * The endpoint is owned by generatecodesamples service owner + * @param petId ID of pet to return (required) + */ + @Headers( + "X-Operation-ID: getPetById" + ) + @GET("/pet/{petId}") + fun getPetById( + @retrofit2.http.Path("petId") petId: Long + ): Single + } diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Category.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Category.kt index 3d3e0e7c..b29b6454 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Category.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Category.kt @@ -7,13 +7,16 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** * A Category used to group pets * @property id Unique ID of the Category * @property name Name of this category */ -data class Category( - @Json(name = "id") @field:Json(name = "id") var id: Long? = null, - @Json(name = "name") @field:Json(name = "name") var name: String? = null +@JsonClass(generateAdapter = true) +data class Category ( + @Json(name = "id") @field:Json(name = "id") var id: Long? = null, + @Json(name = "name") @field:Json(name = "name") var name: String? = null ) + diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Pet.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Pet.kt index bcaf209d..a66f8071 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Pet.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Pet.kt @@ -7,6 +7,7 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** * Represents a specific Pet in the store @@ -16,10 +17,12 @@ import com.squareup.moshi.Json * @property photoUrls Photo URls for this Pet on the bucket * @property tags Pet status in the store */ -data class Pet( - @Json(name = "name") @field:Json(name = "name") var name: String, - @Json(name = "photoUrls") @field:Json(name = "photoUrls") var photoUrls: List, - @Json(name = "category") @field:Json(name = "category") var category: Category? = null, - @Json(name = "id") @field:Json(name = "id") var id: Long? = null, - @Json(name = "tags") @field:Json(name = "tags") var tags: List? = null +@JsonClass(generateAdapter = true) +data class Pet ( + @Json(name = "name") @field:Json(name = "name") var name: String, + @Json(name = "photoUrls") @field:Json(name = "photoUrls") var photoUrls: List, + @Json(name = "category") @field:Json(name = "category") var category: Category? = null, + @Json(name = "id") @field:Json(name = "id") var id: Long? = null, + @Json(name = "tags") @field:Json(name = "tags") var tags: List? = null ) + diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Tag.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Tag.kt index a50cac9d..db5d09b4 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Tag.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/models/Tag.kt @@ -7,13 +7,16 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** * A Tag used to group entities * @property id Unique ID of the Tag * @property name Name of this Tag */ -data class Tag( - @Json(name = "id") @field:Json(name = "id") var id: Long? = null, - @Json(name = "name") @field:Json(name = "name") var name: String? = null +@JsonClass(generateAdapter = true) +data class Tag ( + @Json(name = "id") @field:Json(name = "id") var id: Long? = null, + @Json(name = "name") @field:Json(name = "name") var name: String? = null ) + diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt index f2f344a2..6dfb25cb 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt @@ -4,14 +4,17 @@ package com.yelp.codegen.generatecodesamples.tools @Retention(AnnotationRetention.RUNTIME) annotation class CSV + @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class SSV + @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class TSV + @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class PIPES diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt index 9d2571c5..ea0e943f 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt @@ -20,7 +20,7 @@ internal class EnumToValueConverterFactory : Converter.Factory() { internal class EnumToValueConverter : Converter { override fun convert(enum: Any): String? { val enumName = (enum as Enum<*>).name - val jsonAnnotation: Json? = enum.javaClass.getField(enumName).getAnnotation(Json::class.java) + val jsonAnnotation : Json? = enum.javaClass.getField(enumName).getAnnotation(Json::class.java) // Checking if the Enum is annotated with @Json to get the name. // If not, fallback to enum default (.toString()) diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt index f0cc7617..adc101c6 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt @@ -5,6 +5,7 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import retrofit2.Converter import retrofit2.converter.moshi.MoshiConverterFactory + object GeneratedCodeConverters { private val moshi = Moshi.Builder() .add(XNullableAdapterFactory()) diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt index ce21082d..07dbb85a 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt @@ -42,7 +42,7 @@ class TypesAdapterFactory : JsonAdapter.Factory { */ internal abstract class XNullableJsonAdapter : JsonAdapter() { - abstract fun fromNonNullString(nextString: String): T + abstract fun fromNonNullString(nextString: String) : T override fun fromJson(reader: JsonReader): T? { return if (reader.peek() != JsonReader.Token.NULL) { @@ -57,7 +57,7 @@ internal abstract class XNullableJsonAdapter : JsonAdapter() { internal class LocalDateAdapter : XNullableJsonAdapter() { private val formatter = DateTimeFormatter.ISO_LOCAL_DATE - override fun fromNonNullString(nextString: String): LocalDate = LocalDate.parse(nextString, formatter) + override fun fromNonNullString(nextString: String) : LocalDate = LocalDate.parse(nextString, formatter) override fun toJson(writer: JsonWriter, value: LocalDate?) { value?.let { writer.value(it.format(formatter)) } @@ -70,7 +70,7 @@ internal class ZonedDateTimeAdapter : XNullableJsonAdapter() { override fun fromNonNullString(nextString: String): ZonedDateTime { return try { ZonedDateTime.parse(nextString, formatter) - } catch (parseException: DateTimeException) { + } catch (parseException : DateTimeException) { val localDateTime = LocalDateTime.parse(nextString, formatter) localDateTime.atZone(ZoneId.of("Z")) } diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt index 87c2ef16..8f915205 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt @@ -8,32 +8,26 @@ import java.lang.reflect.Type internal class WrapperConverterFactory(private vararg val factories: Converter.Factory) : Converter.Factory() { - override fun responseBodyConverter( - type: Type, - annotations: Array, - retrofit: Retrofit - ): Converter? { + override fun responseBodyConverter(type: Type, + annotations: Array, + retrofit: Retrofit): Converter? { return factories.mapFirstNonNull { it.responseBodyConverter(type, annotations, retrofit) } } - override fun requestBodyConverter( - type: Type, - parameterAnnotations: Array, - methodAnnotations: Array, - retrofit: Retrofit - ): Converter<*, RequestBody>? { + override fun requestBodyConverter(type: Type, + parameterAnnotations: Array, + methodAnnotations: Array, + retrofit: Retrofit): Converter<*, RequestBody>? { return factories.mapFirstNonNull { it.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit) } } - override fun stringConverter( - type: Type, - annotations: Array, - retrofit: Retrofit - ): Converter<*, String>? { + override fun stringConverter(type: Type, + annotations: Array, + retrofit: Retrofit): Converter<*, String>? { return factories.mapFirstNonNull { it.stringConverter(type, annotations, retrofit) } diff --git a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt index 44822056..5fb93940 100644 --- a/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt +++ b/samples/generated-code/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt @@ -38,12 +38,13 @@ class XNullableAdapterFactory : JsonAdapter.Factory { nextAdapter?.toJson(writer, value) } } + } } return null } - private fun Set.removeXNullableAnnotation(): MutableSet { + private fun Set.removeXNullableAnnotation():MutableSet{ return this.filter { it !is XNullable }.toMutableSet() } } diff --git a/samples/generated-code/src/main/java/swagger.json b/samples/generated-code/src/main/java/swagger.json index bf0e78ad..5e295840 100644 --- a/samples/generated-code/src/main/java/swagger.json +++ b/samples/generated-code/src/main/java/swagger.json @@ -1,104 +1 @@ -{ - "definitions": { - "Category": { - "description": "A Category used to group pets", - "properties": { - "id": { - "description": "Unique ID of the Category", - "format": "int64", - "type": "integer" - }, - "name": { - "description": "Name of this category", - "type": "string" - } - }, - "type": "object" - }, - "Pet": { - "description": "Represents a specific Pet in the store", - "properties": { - "category": { - "$ref": "#/definitions/Category", - "description": "Optional category of the pet" - }, - "id": { - "description": "Unique ID of this Pet", - "format": "int64", - "type": "integer" - }, - "name": { - "description": "Name of this specific pet", - "type": "string" - }, - "photoUrls": { - "description": "Photo URls for this Pet on the bucket", - "items": { - "type": "string" - }, - "type": "array" - }, - "tags": { - "description": "Pet status in the store", - "items": { - "$ref": "#/definitions/Tag" - }, - "type": "array" - } - }, - "required": [ - "name", - "photoUrls" - ], - "type": "object" - }, - "Tag": { - "description": "A Tag used to group entities", - "properties": { - "id": { - "description": "Unique ID of the Tag", - "format": "int64", - "type": "integer" - }, - "name": { - "description": "Name of this Tag", - "type": "string" - } - }, - "type": "object" - } - }, - "info": { - "description": "This is a simplified version of the sample server Petstore server.", - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "paths": { - "/pet/{petId}": { - "get": { - "description": "Returns a single pet", - "operationId": "getPetById", - "parameters": [ - { - "description": "ID of pet to return", - "format": "int64", - "in": "path", - "name": "petId", - "required": true, - "type": "integer" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/Pet" - } - } - }, - "summary": "Find pet by ID" - } - } - }, - "swagger": "2.0" -} +{"swagger":"2.0","info":{"description":"This is a simplified version of the sample server Petstore server.","version":"1.0.0","title":"Swagger Petstore"},"paths":{"/pet/{petId}":{"get":{"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,"type":"integer","format":"int64"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Pet"}}}}}},"definitions":{"Category":{"type":"object","properties":{"id":{"type":"integer","format":"int64","description":"Unique ID of the Category"},"name":{"type":"string","description":"Name of this category"}},"description":"A Category used to group pets"},"Pet":{"type":"object","required":["name","photoUrls"],"properties":{"category":{"description":"Optional category of the pet","$ref":"#/definitions/Category"},"id":{"type":"integer","format":"int64","description":"Unique ID of this Pet"},"name":{"type":"string","description":"Name of this specific pet"},"photoUrls":{"type":"array","description":"Photo URls for this Pet on the bucket","items":{"type":"string"}},"tags":{"type":"array","description":"Pet status in the store","items":{"$ref":"#/definitions/Tag"}}},"description":"Represents a specific Pet in the store"},"Tag":{"type":"object","properties":{"id":{"type":"integer","format":"int64","description":"Unique ID of the Tag"},"name":{"type":"string","description":"Name of this Tag"}},"description":"A Tag used to group entities"}}} \ No newline at end of file diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/ResourceApi.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/ResourceApi.kt index 71fb0fcb..abef23c6 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/ResourceApi.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/ResourceApi.kt @@ -6,6 +6,8 @@ package com.yelp.codegen.generatecodesamples.apis +import okhttp3.RequestBody + import com.yelp.codegen.generatecodesamples.models.EmptyModel import com.yelp.codegen.generatecodesamples.models.FormatResponses import com.yelp.codegen.generatecodesamples.models.NestedAdditionalProperties @@ -24,152 +26,160 @@ import retrofit2.http.Headers @JvmSuppressWildcards interface ResourceApi { - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_empty_endpoint" - ) - @GET("/empty_endpoint") - fun getEmptyEndpoint(): Single - - /** - * The endpoint is owned by junittests service owner - * @param propertyFormat (required) - */ - @Headers( - "X-Operation-ID: get_format_endpoint" - ) - @GET("/format_endpoint/{property_format}") - fun getFormatEndpoint( - @retrofit2.http.Path("property_format") propertyFormat: String - ): Single - - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_nested_additional_properties" - ) - @GET("/nested_additional_properties") - fun getNestedAdditionalProperties(): Single - - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_nested_additional_properties_custom_description" - ) - @GET("/nested_additional_properties/custom_description") - fun getNestedAdditionalPropertiesCustomDescription(): Single - - /** - * The endpoint is owned by junittests service owner - * @param valueType (required) - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_property_array" - ) - @GET("/property_array/{value_type}/{size}") - fun getPropertyArray( - @retrofit2.http.Path("value_type") valueType: String, - @retrofit2.http.Path("size") size: String - ): Single - - /** - * The endpoint is owned by junittests service owner - * @param valueType (required) - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_property_map" - ) - @GET("/property_map/{value_type}/{size}") - fun getPropertyMap( - @retrofit2.http.Path("value_type") valueType: String, - @retrofit2.http.Path("size") size: String - ): Single - - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_required_type_endpoint" - ) - @GET("/required/type_endpoint") - fun getRequiredTypeEndpoint(): Single - - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_reserved_keywords" - ) - @GET("/reserved_keywords") - fun getReservedKeywords(): Single - - /** - * Test symbols in parameter name - * Make sure that symbols in parameter name are treated properly - * The endpoint is owned by junittests service owner - * @param parameter (optional) - * @param brackets (optional) - * @param bracketsWithText (optional) - * @param dot (optional) - * @param dotWithText (optional) - */ - @Headers( - "X-Operation-ID: getSymbolsInParameterName" - ) - @GET("/symbols/in/parameter/name") - fun getSymbolsInParameterName( - @retrofit2.http.Query("parameter") parameter: String?, - @retrofit2.http.Query("brackets[]") brackets: String?, - @retrofit2.http.Query("brackets[withText]") bracketsWithText: String?, - @retrofit2.http.Query("dot.") dot: String?, - @retrofit2.http.Query("dot.withText") dotWithText: String? - ): Completable - - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_top_level_enum" - ) - @GET("/top_level_enum") - fun getTopLevelEnum(): Single - - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_top_level_enum_nested" - ) - @GET("/top_level_enum/nested") - fun getTopLevelEnumNested(): Single>> - - /** - * The endpoint is owned by junittests service owner - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_top_level_map" - ) - @GET("/top_level_map/{size}") - fun getTopLevelMap( - @retrofit2.http.Path("size") size: String - ): Single - - /** - * The endpoint is owned by junittests service owner - * @param propertyType (required) - */ - @Headers( - "X-Operation-ID: get_type_endpoint" - ) - @GET("/type_endpoint/{property_type}") - fun getTypeEndpoint( - @retrofit2.http.Path("property_type") propertyType: String - ): Single + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_empty_endpoint" + ) + @GET("/empty_endpoint") + fun getEmptyEndpoint() + : Single + + /** + * The endpoint is owned by junittests service owner + * @param propertyFormat (required) + */ + @Headers( + "X-Operation-ID: get_format_endpoint" + ) + @GET("/format_endpoint/{property_format}") + fun getFormatEndpoint( + @retrofit2.http.Path("property_format") propertyFormat: String + ): Single + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_nested_additional_properties" + ) + @GET("/nested_additional_properties") + fun getNestedAdditionalProperties() + : Single + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_nested_additional_properties_custom_description" + ) + @GET("/nested_additional_properties/custom_description") + fun getNestedAdditionalPropertiesCustomDescription() + : Single + + /** + * The endpoint is owned by junittests service owner + * @param valueType (required) + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_property_array" + ) + @GET("/property_array/{value_type}/{size}") + fun getPropertyArray( + @retrofit2.http.Path("value_type") valueType: String, + @retrofit2.http.Path("size") size: String + ): Single + + /** + * The endpoint is owned by junittests service owner + * @param valueType (required) + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_property_map" + ) + @GET("/property_map/{value_type}/{size}") + fun getPropertyMap( + @retrofit2.http.Path("value_type") valueType: String, + @retrofit2.http.Path("size") size: String + ): Single + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_required_type_endpoint" + ) + @GET("/required/type_endpoint") + fun getRequiredTypeEndpoint() + : Single + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_reserved_keywords" + ) + @GET("/reserved_keywords") + fun getReservedKeywords() + : Single + + /** + * Test symbols in parameter name + * Make sure that symbols in parameter name are treated properly + * The endpoint is owned by junittests service owner + * @param parameter (optional) + * @param brackets (optional) + * @param bracketsWithText (optional) + * @param dot (optional) + * @param dotWithText (optional) + */ + @Headers( + "X-Operation-ID: getSymbolsInParameterName" + ) + @GET("/symbols/in/parameter/name") + fun getSymbolsInParameterName( + @retrofit2.http.Query("parameter") parameter: String?, + @retrofit2.http.Query("brackets[]") brackets: String?, + @retrofit2.http.Query("brackets[withText]") bracketsWithText: String?, + @retrofit2.http.Query("dot.") dot: String?, + @retrofit2.http.Query("dot.withText") dotWithText: String? + ): Completable + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_top_level_enum" + ) + @GET("/top_level_enum") + fun getTopLevelEnum() + : Single + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_top_level_enum_nested" + ) + @GET("/top_level_enum/nested") + fun getTopLevelEnumNested() + : Single>> + + /** + * The endpoint is owned by junittests service owner + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_top_level_map" + ) + @GET("/top_level_map/{size}") + fun getTopLevelMap( + @retrofit2.http.Path("size") size: String + ): Single + + /** + * The endpoint is owned by junittests service owner + * @param propertyType (required) + */ + @Headers( + "X-Operation-ID: get_type_endpoint" + ) + @GET("/type_endpoint/{property_type}") + fun getTypeEndpoint( + @retrofit2.http.Path("property_type") propertyType: String + ): Single + } diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/XnullableApi.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/XnullableApi.kt index ac9e1779..ea3b5ae5 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/XnullableApi.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/apis/XnullableApi.kt @@ -6,6 +6,8 @@ package com.yelp.codegen.generatecodesamples.apis +import okhttp3.RequestBody + import com.yelp.codegen.generatecodesamples.models.XnullableFormatResponses import com.yelp.codegen.generatecodesamples.models.XnullableNestedAdditionalProperties import com.yelp.codegen.generatecodesamples.models.XnullablePropertyArray @@ -20,100 +22,102 @@ import retrofit2.http.Headers @JvmSuppressWildcards interface XnullableApi { - /** - * The endpoint is owned by junittests service owner - * @param propertyFormat (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_format_endpoint" - ) - @GET("/xnullable/format_endpoint/{property_format}") - fun getXnullableFormatEndpoint( - @retrofit2.http.Path("property_format") propertyFormat: String - ): Single + /** + * The endpoint is owned by junittests service owner + * @param propertyFormat (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_format_endpoint" + ) + @GET("/xnullable/format_endpoint/{property_format}") + fun getXnullableFormatEndpoint( + @retrofit2.http.Path("property_format") propertyFormat: String + ): Single + + /** + * The endpoint is owned by junittests service owner + */ + @Headers( + "X-Operation-ID: get_xnullable_nested_additional_properties" + ) + @GET("/xnullable/nested_additional_properties") + fun getXnullableNestedAdditionalProperties() + : Single - /** - * The endpoint is owned by junittests service owner - */ - @Headers( - "X-Operation-ID: get_xnullable_nested_additional_properties" - ) - @GET("/xnullable/nested_additional_properties") - fun getXnullableNestedAdditionalProperties(): Single + /** + * The endpoint is owned by junittests service owner + * @param valueType (required) + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_property_array" + ) + @GET("/xnullable/property_array/{value_type}/{size}") + fun getXnullablePropertyArray( + @retrofit2.http.Path("value_type") valueType: String, + @retrofit2.http.Path("size") size: String + ): Single - /** - * The endpoint is owned by junittests service owner - * @param valueType (required) - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_property_array" - ) - @GET("/xnullable/property_array/{value_type}/{size}") - fun getXnullablePropertyArray( - @retrofit2.http.Path("value_type") valueType: String, - @retrofit2.http.Path("size") size: String - ): Single + /** + * The endpoint is owned by junittests service owner + * @param valueType (required) + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_property_map" + ) + @GET("/xnullable/property_map/{value_type}/{size}") + fun getXnullablePropertyMap( + @retrofit2.http.Path("value_type") valueType: String, + @retrofit2.http.Path("size") size: String + ): Single - /** - * The endpoint is owned by junittests service owner - * @param valueType (required) - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_property_map" - ) - @GET("/xnullable/property_map/{value_type}/{size}") - fun getXnullablePropertyMap( - @retrofit2.http.Path("value_type") valueType: String, - @retrofit2.http.Path("size") size: String - ): Single + /** + * The endpoint is owned by junittests service owner + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_required_property_array" + ) + @GET("/xnullable/required/property_array/{size}") + fun getXnullableRequiredPropertyArray( + @retrofit2.http.Path("size") size: String + ): Single - /** - * The endpoint is owned by junittests service owner - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_required_property_array" - ) - @GET("/xnullable/required/property_array/{size}") - fun getXnullableRequiredPropertyArray( - @retrofit2.http.Path("size") size: String - ): Single + /** + * The endpoint is owned by junittests service owner + * @param size (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_required_property_map" + ) + @GET("/xnullable/required/property_map/{size}") + fun getXnullableRequiredPropertyMap( + @retrofit2.http.Path("size") size: String + ): Single - /** - * The endpoint is owned by junittests service owner - * @param size (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_required_property_map" - ) - @GET("/xnullable/required/property_map/{size}") - fun getXnullableRequiredPropertyMap( - @retrofit2.http.Path("size") size: String - ): Single + /** + * The endpoint is owned by junittests service owner + * @param propertyType (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_required_type_endpoint" + ) + @GET("/xnullable/required/type_endpoint/{property_type}") + fun getXnullableRequiredTypeEndpoint( + @retrofit2.http.Path("property_type") propertyType: String + ): Single - /** - * The endpoint is owned by junittests service owner - * @param propertyType (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_required_type_endpoint" - ) - @GET("/xnullable/required/type_endpoint/{property_type}") - fun getXnullableRequiredTypeEndpoint( - @retrofit2.http.Path("property_type") propertyType: String - ): Single + /** + * The endpoint is owned by junittests service owner + * @param propertyType (required) + */ + @Headers( + "X-Operation-ID: get_xnullable_type_endpoint" + ) + @GET("/xnullable/type_endpoint/{property_type}") + fun getXnullableTypeEndpoint( + @retrofit2.http.Path("property_type") propertyType: String + ): Single - /** - * The endpoint is owned by junittests service owner - * @param propertyType (required) - */ - @Headers( - "X-Operation-ID: get_xnullable_type_endpoint" - ) - @GET("/xnullable/type_endpoint/{property_type}") - fun getXnullableTypeEndpoint( - @retrofit2.http.Path("property_type") propertyType: String - ): Single } diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/EmptyModel.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/EmptyModel.kt index 90e2967d..476ef755 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/EmptyModel.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/EmptyModel.kt @@ -6,7 +6,11 @@ package com.yelp.codegen.generatecodesamples.models +import com.squareup.moshi.JsonClass + /** - * + * */ -class EmptyModel +@JsonClass(generateAdapter = true) +class EmptyModel + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/FormatResponses.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/FormatResponses.kt index ffb411d1..70c5680f 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/FormatResponses.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/FormatResponses.kt @@ -7,26 +7,30 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import org.threeten.bp.LocalDate import org.threeten.bp.ZonedDateTime /** - * - * @property dateProperty - * @property datetimeProperty - * @property enumProperty + * + * @property dateProperty + * @property datetimeProperty + * @property enumProperty */ -data class FormatResponses( - @Json(name = "date_property") @field:Json(name = "date_property") var dateProperty: LocalDate? = null, - @Json(name = "datetime_property") @field:Json(name = "datetime_property") var datetimeProperty: ZonedDateTime? = null, - @Json(name = "enum_property") @field:Json(name = "enum_property") var enumProperty: FormatResponses.EnumPropertyEnum? = null +@JsonClass(generateAdapter = true) +data class FormatResponses ( + @Json(name = "date_property") @field:Json(name = "date_property") var dateProperty: LocalDate? = null, + @Json(name = "datetime_property") @field:Json(name = "datetime_property") var datetimeProperty: ZonedDateTime? = null, + @Json(name = "enum_property") @field:Json(name = "enum_property") var enumProperty: FormatResponses.EnumPropertyEnum? = null ) { /** - * + * * Values: VALUE1, VALUE2 */ - enum class EnumPropertyEnum(val value: String) { + @JsonClass(generateAdapter = false) + enum class EnumPropertyEnum(val value: String){ @Json(name = "VALUE1") VALUE1("VALUE1"), @Json(name = "VALUE2") VALUE2("VALUE2") } } + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalProperties.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalProperties.kt index 8e4a44bf..db5b8890 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalProperties.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalProperties.kt @@ -6,4 +6,8 @@ package com.yelp.codegen.generatecodesamples.models + + typealias NestedAdditionalProperties = Map + + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalPropertiesCustomDescription.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalPropertiesCustomDescription.kt index 9a05a438..cceafe63 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalPropertiesCustomDescription.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/NestedAdditionalPropertiesCustomDescription.kt @@ -6,4 +6,8 @@ package com.yelp.codegen.generatecodesamples.models + + typealias NestedAdditionalPropertiesCustomDescription = NestedAdditionalProperties + + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyArray.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyArray.kt index 9ff43540..8cd7fb68 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyArray.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyArray.kt @@ -7,14 +7,17 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import java.math.BigDecimal /** - * - * @property numberArray - * @property stringArray + * + * @property numberArray + * @property stringArray */ -data class PropertyArray( - @Json(name = "number_array") @field:Json(name = "number_array") var numberArray: List? = null, - @Json(name = "string_array") @field:Json(name = "string_array") var stringArray: List? = null +@JsonClass(generateAdapter = true) +data class PropertyArray ( + @Json(name = "number_array") @field:Json(name = "number_array") var numberArray: List? = null, + @Json(name = "string_array") @field:Json(name = "string_array") var stringArray: List? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyMap.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyMap.kt index d9352b49..8091d371 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyMap.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/PropertyMap.kt @@ -7,16 +7,19 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import java.math.BigDecimal /** - * - * @property numberMap - * @property objectMap - * @property stringMap + * + * @property numberMap + * @property objectMap + * @property stringMap */ -data class PropertyMap( - @Json(name = "number_map") @field:Json(name = "number_map") var numberMap: Map? = null, - @Json(name = "object_map") @field:Json(name = "object_map") var objectMap: Map? = null, - @Json(name = "string_map") @field:Json(name = "string_map") var stringMap: Map? = null +@JsonClass(generateAdapter = true) +data class PropertyMap ( + @Json(name = "number_map") @field:Json(name = "number_map") var numberMap: Map? = null, + @Json(name = "object_map") @field:Json(name = "object_map") var objectMap: Map? = null, + @Json(name = "string_map") @field:Json(name = "string_map") var stringMap: Map? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/RequiredTypeResponses.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/RequiredTypeResponses.kt index da49f88d..612a740a 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/RequiredTypeResponses.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/RequiredTypeResponses.kt @@ -7,29 +7,33 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import java.math.BigDecimal /** - * - * @property booleanProperty - * @property enumProperty - * @property integerProperty - * @property numberProperty - * @property stringProperty + * + * @property booleanProperty + * @property enumProperty + * @property integerProperty + * @property numberProperty + * @property stringProperty */ -data class RequiredTypeResponses( - @Json(name = "boolean_property") @field:Json(name = "boolean_property") var booleanProperty: Boolean, - @Json(name = "enum_property") @field:Json(name = "enum_property") var enumProperty: RequiredTypeResponses.EnumPropertyEnum, - @Json(name = "integer_property") @field:Json(name = "integer_property") var integerProperty: Int, - @Json(name = "number_property") @field:Json(name = "number_property") var numberProperty: BigDecimal, - @Json(name = "string_property") @field:Json(name = "string_property") var stringProperty: String +@JsonClass(generateAdapter = true) +data class RequiredTypeResponses ( + @Json(name = "boolean_property") @field:Json(name = "boolean_property") var booleanProperty: Boolean, + @Json(name = "enum_property") @field:Json(name = "enum_property") var enumProperty: RequiredTypeResponses.EnumPropertyEnum, + @Json(name = "integer_property") @field:Json(name = "integer_property") var integerProperty: Int, + @Json(name = "number_property") @field:Json(name = "number_property") var numberProperty: BigDecimal, + @Json(name = "string_property") @field:Json(name = "string_property") var stringProperty: String ) { /** - * + * * Values: VALUE1, VALUE2 */ - enum class EnumPropertyEnum(val value: String) { + @JsonClass(generateAdapter = false) + enum class EnumPropertyEnum(val value: String){ @Json(name = "VALUE1") VALUE1("VALUE1"), @Json(name = "VALUE2") VALUE2("VALUE2") } } + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/ReservedKeywords.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/ReservedKeywords.kt index 4251ddef..5f12dccf 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/ReservedKeywords.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/ReservedKeywords.kt @@ -7,21 +7,24 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** - * - * @property `class` - * @property `for` - * @property `operator` - * @property `val` - * @property `var` - * @property `when` + * + * @property `class` + * @property `for` + * @property `operator` + * @property `val` + * @property `var` + * @property `when` */ -data class ReservedKeywords( - @Json(name = "class") @field:Json(name = "class") var `class`: String? = null, - @Json(name = "for") @field:Json(name = "for") var `for`: String? = null, - @Json(name = "operator") @field:Json(name = "operator") var `operator`: String? = null, - @Json(name = "val") @field:Json(name = "val") var `val`: String? = null, - @Json(name = "var") @field:Json(name = "var") var `var`: String? = null, - @Json(name = "when") @field:Json(name = "when") var `when`: String? = null +@JsonClass(generateAdapter = true) +data class ReservedKeywords ( + @Json(name = "class") @field:Json(name = "class") var `class`: String? = null, + @Json(name = "for") @field:Json(name = "for") var `for`: String? = null, + @Json(name = "operator") @field:Json(name = "operator") var `operator`: String? = null, + @Json(name = "val") @field:Json(name = "val") var `val`: String? = null, + @Json(name = "var") @field:Json(name = "var") var `var`: String? = null, + @Json(name = "when") @field:Json(name = "when") var `when`: String? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelEnum.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelEnum.kt index 4d9819e5..fb91d754 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelEnum.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelEnum.kt @@ -7,12 +7,15 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** -* +* * Values: VALUE1,VALUE2 */ -enum class TopLevelEnum(val value: String) { +@JsonClass(generateAdapter = false) +enum class TopLevelEnum(val value: String){ @Json(name = "TOP_LEVEL_VALUE1") VALUE1("TOP_LEVEL_VALUE1"), @Json(name = "TOP_LEVEL_VALUE2") VALUE2("TOP_LEVEL_VALUE2") } + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelMap.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelMap.kt index c003e56e..f7821156 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelMap.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TopLevelMap.kt @@ -6,4 +6,8 @@ package com.yelp.codegen.generatecodesamples.models + + typealias TopLevelMap = Map + + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TypeResponses.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TypeResponses.kt index bd11fa0c..2466091f 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TypeResponses.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/TypeResponses.kt @@ -7,18 +7,21 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import java.math.BigDecimal /** - * - * @property booleanProperty - * @property integerProperty - * @property numberProperty - * @property stringProperty + * + * @property booleanProperty + * @property integerProperty + * @property numberProperty + * @property stringProperty */ -data class TypeResponses( - @Json(name = "boolean_property") @field:Json(name = "boolean_property") var booleanProperty: Boolean? = null, - @Json(name = "integer_property") @field:Json(name = "integer_property") var integerProperty: Int? = null, - @Json(name = "number_property") @field:Json(name = "number_property") var numberProperty: BigDecimal? = null, - @Json(name = "string_property") @field:Json(name = "string_property") var stringProperty: String? = null +@JsonClass(generateAdapter = true) +data class TypeResponses ( + @Json(name = "boolean_property") @field:Json(name = "boolean_property") var booleanProperty: Boolean? = null, + @Json(name = "integer_property") @field:Json(name = "integer_property") var integerProperty: Int? = null, + @Json(name = "number_property") @field:Json(name = "number_property") var numberProperty: BigDecimal? = null, + @Json(name = "string_property") @field:Json(name = "string_property") var stringProperty: String? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableFormatResponses.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableFormatResponses.kt index 5d6b003a..379a72a9 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableFormatResponses.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableFormatResponses.kt @@ -7,18 +7,21 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import org.threeten.bp.LocalDate import org.threeten.bp.ZonedDateTime /** - * - * @property dateProperty - * @property datetimeProperty - * @property doubleProperty + * + * @property dateProperty + * @property datetimeProperty + * @property doubleProperty */ -data class XnullableFormatResponses( - @Json(name = "date_property") @field:Json(name = "date_property") @XNullable var dateProperty: LocalDate? = null, - @Json(name = "datetime_property") @field:Json(name = "datetime_property") @XNullable var datetimeProperty: ZonedDateTime? = null, - @Json(name = "double_property") @field:Json(name = "double_property") @XNullable var doubleProperty: Double? = null +@JsonClass(generateAdapter = true) +data class XnullableFormatResponses ( + @Json(name = "date_property") @field:Json(name = "date_property") @XNullable var dateProperty: LocalDate? = null, + @Json(name = "datetime_property") @field:Json(name = "datetime_property") @XNullable var datetimeProperty: ZonedDateTime? = null, + @Json(name = "double_property") @field:Json(name = "double_property") @XNullable var doubleProperty: Double? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableMap.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableMap.kt index 0b60d554..1e909ccb 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableMap.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableMap.kt @@ -6,4 +6,8 @@ package com.yelp.codegen.generatecodesamples.models + + typealias XnullableMap = Map + + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableNestedAdditionalProperties.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableNestedAdditionalProperties.kt index d603a32d..79d9a70f 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableNestedAdditionalProperties.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableNestedAdditionalProperties.kt @@ -6,4 +6,8 @@ package com.yelp.codegen.generatecodesamples.models + + typealias XnullableNestedAdditionalProperties = Map + + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyArray.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyArray.kt index 0858110b..67e2d7e9 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyArray.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyArray.kt @@ -7,15 +7,18 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import java.math.BigDecimal /** - * - * @property numberArray - * @property stringArray + * + * @property numberArray + * @property stringArray */ -data class XnullablePropertyArray( - @Json(name = "number_array") @field:Json(name = "number_array") @XNullable var numberArray: List? = null, - @Json(name = "string_array") @field:Json(name = "string_array") @XNullable var stringArray: List? = null +@JsonClass(generateAdapter = true) +data class XnullablePropertyArray ( + @Json(name = "number_array") @field:Json(name = "number_array") @XNullable var numberArray: List? = null, + @Json(name = "string_array") @field:Json(name = "string_array") @XNullable var stringArray: List? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyMap.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyMap.kt index 729245ff..4a3c097b 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyMap.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullablePropertyMap.kt @@ -7,17 +7,20 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import java.math.BigDecimal /** - * - * @property numberMap - * @property objectMap - * @property stringMap + * + * @property numberMap + * @property objectMap + * @property stringMap */ -data class XnullablePropertyMap( - @Json(name = "number_map") @field:Json(name = "number_map") @XNullable var numberMap: Map? = null, - @Json(name = "object_map") @field:Json(name = "object_map") @XNullable var objectMap: Map? = null, - @Json(name = "string_map") @field:Json(name = "string_map") @XNullable var stringMap: Map? = null +@JsonClass(generateAdapter = true) +data class XnullablePropertyMap ( + @Json(name = "number_map") @field:Json(name = "number_map") @XNullable var numberMap: Map? = null, + @Json(name = "object_map") @field:Json(name = "object_map") @XNullable var objectMap: Map? = null, + @Json(name = "string_map") @field:Json(name = "string_map") @XNullable var stringMap: Map? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyArray.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyArray.kt index 5928498a..03c017ae 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyArray.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyArray.kt @@ -7,15 +7,18 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import java.math.BigDecimal /** - * - * @property numberArray - * @property stringArray + * + * @property numberArray + * @property stringArray */ -data class XnullableRequiredPropertyArray( - @Json(name = "number_array") @field:Json(name = "number_array") @XNullable var numberArray: List? = null, - @Json(name = "string_array") @field:Json(name = "string_array") @XNullable var stringArray: List? = null +@JsonClass(generateAdapter = true) +data class XnullableRequiredPropertyArray ( + @Json(name = "number_array") @field:Json(name = "number_array") @XNullable var numberArray: List? = null, + @Json(name = "string_array") @field:Json(name = "string_array") @XNullable var stringArray: List? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyMap.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyMap.kt index a128e93d..29daec84 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyMap.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredPropertyMap.kt @@ -7,17 +7,20 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import java.math.BigDecimal /** - * - * @property numberMap - * @property objectMap - * @property stringMap + * + * @property numberMap + * @property objectMap + * @property stringMap */ -data class XnullableRequiredPropertyMap( - @Json(name = "number_map") @field:Json(name = "number_map") @XNullable var numberMap: Map? = null, - @Json(name = "object_map") @field:Json(name = "object_map") @XNullable var objectMap: Map? = null, - @Json(name = "string_map") @field:Json(name = "string_map") @XNullable var stringMap: Map? = null +@JsonClass(generateAdapter = true) +data class XnullableRequiredPropertyMap ( + @Json(name = "number_map") @field:Json(name = "number_map") @XNullable var numberMap: Map? = null, + @Json(name = "object_map") @field:Json(name = "object_map") @XNullable var objectMap: Map? = null, + @Json(name = "string_map") @field:Json(name = "string_map") @XNullable var stringMap: Map? = null ) + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredTypeResponses.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredTypeResponses.kt index b5a62c72..8fdba73d 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredTypeResponses.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableRequiredTypeResponses.kt @@ -7,30 +7,34 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import java.math.BigDecimal /** - * - * @property booleanProperty - * @property enumProperty - * @property integerProperty - * @property numberProperty - * @property stringProperty + * + * @property booleanProperty + * @property enumProperty + * @property integerProperty + * @property numberProperty + * @property stringProperty */ -data class XnullableRequiredTypeResponses( - @Json(name = "boolean_property") @field:Json(name = "boolean_property") @XNullable var booleanProperty: Boolean? = null, - @Json(name = "enum_property") @field:Json(name = "enum_property") @XNullable var enumProperty: XnullableRequiredTypeResponses.EnumPropertyEnum? = null, - @Json(name = "integer_property") @field:Json(name = "integer_property") @XNullable var integerProperty: Int? = null, - @Json(name = "number_property") @field:Json(name = "number_property") @XNullable var numberProperty: BigDecimal? = null, - @Json(name = "string_property") @field:Json(name = "string_property") @XNullable var stringProperty: String? = null +@JsonClass(generateAdapter = true) +data class XnullableRequiredTypeResponses ( + @Json(name = "boolean_property") @field:Json(name = "boolean_property") @XNullable var booleanProperty: Boolean? = null, + @Json(name = "enum_property") @field:Json(name = "enum_property") @XNullable var enumProperty: XnullableRequiredTypeResponses.EnumPropertyEnum? = null, + @Json(name = "integer_property") @field:Json(name = "integer_property") @XNullable var integerProperty: Int? = null, + @Json(name = "number_property") @field:Json(name = "number_property") @XNullable var numberProperty: BigDecimal? = null, + @Json(name = "string_property") @field:Json(name = "string_property") @XNullable var stringProperty: String? = null ) { /** - * + * * Values: VALUE1, VALUE2 */ - enum class EnumPropertyEnum(val value: String) { + @JsonClass(generateAdapter = false) + enum class EnumPropertyEnum(val value: String){ @Json(name = "VALUE1") VALUE1("VALUE1"), @Json(name = "VALUE2") VALUE2("VALUE2") } } + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableTypeResponses.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableTypeResponses.kt index dea572f2..cd19101e 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableTypeResponses.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/models/XnullableTypeResponses.kt @@ -7,30 +7,34 @@ package com.yelp.codegen.generatecodesamples.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.yelp.codegen.generatecodesamples.tools.XNullable import java.math.BigDecimal /** - * - * @property booleanProperty - * @property enumProperty - * @property integerProperty - * @property numberProperty - * @property stringProperty + * + * @property booleanProperty + * @property enumProperty + * @property integerProperty + * @property numberProperty + * @property stringProperty */ -data class XnullableTypeResponses( - @Json(name = "boolean_property") @field:Json(name = "boolean_property") @XNullable var booleanProperty: Boolean? = null, - @Json(name = "enum_property") @field:Json(name = "enum_property") @XNullable var enumProperty: XnullableTypeResponses.EnumPropertyEnum? = null, - @Json(name = "integer_property") @field:Json(name = "integer_property") @XNullable var integerProperty: Int? = null, - @Json(name = "number_property") @field:Json(name = "number_property") @XNullable var numberProperty: BigDecimal? = null, - @Json(name = "string_property") @field:Json(name = "string_property") @XNullable var stringProperty: String? = null +@JsonClass(generateAdapter = true) +data class XnullableTypeResponses ( + @Json(name = "boolean_property") @field:Json(name = "boolean_property") @XNullable var booleanProperty: Boolean? = null, + @Json(name = "enum_property") @field:Json(name = "enum_property") @XNullable var enumProperty: XnullableTypeResponses.EnumPropertyEnum? = null, + @Json(name = "integer_property") @field:Json(name = "integer_property") @XNullable var integerProperty: Int? = null, + @Json(name = "number_property") @field:Json(name = "number_property") @XNullable var numberProperty: BigDecimal? = null, + @Json(name = "string_property") @field:Json(name = "string_property") @XNullable var stringProperty: String? = null ) { /** - * + * * Values: VALUE1, VALUE2 */ - enum class EnumPropertyEnum(val value: String) { + @JsonClass(generateAdapter = false) + enum class EnumPropertyEnum(val value: String){ @Json(name = "VALUE1") VALUE1("VALUE1"), @Json(name = "VALUE2") VALUE2("VALUE2") } } + diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt index f2f344a2..6dfb25cb 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/CollectionFormats.kt @@ -4,14 +4,17 @@ package com.yelp.codegen.generatecodesamples.tools @Retention(AnnotationRetention.RUNTIME) annotation class CSV + @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class SSV + @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class TSV + @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class PIPES diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt index 9d2571c5..ea0e943f 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/EnumToValueConverterFactory.kt @@ -20,7 +20,7 @@ internal class EnumToValueConverterFactory : Converter.Factory() { internal class EnumToValueConverter : Converter { override fun convert(enum: Any): String? { val enumName = (enum as Enum<*>).name - val jsonAnnotation: Json? = enum.javaClass.getField(enumName).getAnnotation(Json::class.java) + val jsonAnnotation : Json? = enum.javaClass.getField(enumName).getAnnotation(Json::class.java) // Checking if the Enum is annotated with @Json to get the name. // If not, fallback to enum default (.toString()) diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt index f0cc7617..adc101c6 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/GeneratedCodeConverters.kt @@ -5,6 +5,7 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import retrofit2.Converter import retrofit2.converter.moshi.MoshiConverterFactory + object GeneratedCodeConverters { private val moshi = Moshi.Builder() .add(XNullableAdapterFactory()) diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt index ce21082d..07dbb85a 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/TypesAdapters.kt @@ -42,7 +42,7 @@ class TypesAdapterFactory : JsonAdapter.Factory { */ internal abstract class XNullableJsonAdapter : JsonAdapter() { - abstract fun fromNonNullString(nextString: String): T + abstract fun fromNonNullString(nextString: String) : T override fun fromJson(reader: JsonReader): T? { return if (reader.peek() != JsonReader.Token.NULL) { @@ -57,7 +57,7 @@ internal abstract class XNullableJsonAdapter : JsonAdapter() { internal class LocalDateAdapter : XNullableJsonAdapter() { private val formatter = DateTimeFormatter.ISO_LOCAL_DATE - override fun fromNonNullString(nextString: String): LocalDate = LocalDate.parse(nextString, formatter) + override fun fromNonNullString(nextString: String) : LocalDate = LocalDate.parse(nextString, formatter) override fun toJson(writer: JsonWriter, value: LocalDate?) { value?.let { writer.value(it.format(formatter)) } @@ -70,7 +70,7 @@ internal class ZonedDateTimeAdapter : XNullableJsonAdapter() { override fun fromNonNullString(nextString: String): ZonedDateTime { return try { ZonedDateTime.parse(nextString, formatter) - } catch (parseException: DateTimeException) { + } catch (parseException : DateTimeException) { val localDateTime = LocalDateTime.parse(nextString, formatter) localDateTime.atZone(ZoneId.of("Z")) } diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt index 87c2ef16..8f915205 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/WrapperConverterFactory.kt @@ -8,32 +8,26 @@ import java.lang.reflect.Type internal class WrapperConverterFactory(private vararg val factories: Converter.Factory) : Converter.Factory() { - override fun responseBodyConverter( - type: Type, - annotations: Array, - retrofit: Retrofit - ): Converter? { + override fun responseBodyConverter(type: Type, + annotations: Array, + retrofit: Retrofit): Converter? { return factories.mapFirstNonNull { it.responseBodyConverter(type, annotations, retrofit) } } - override fun requestBodyConverter( - type: Type, - parameterAnnotations: Array, - methodAnnotations: Array, - retrofit: Retrofit - ): Converter<*, RequestBody>? { + override fun requestBodyConverter(type: Type, + parameterAnnotations: Array, + methodAnnotations: Array, + retrofit: Retrofit): Converter<*, RequestBody>? { return factories.mapFirstNonNull { it.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit) } } - override fun stringConverter( - type: Type, - annotations: Array, - retrofit: Retrofit - ): Converter<*, String>? { + override fun stringConverter(type: Type, + annotations: Array, + retrofit: Retrofit): Converter<*, String>? { return factories.mapFirstNonNull { it.stringConverter(type, annotations, retrofit) } diff --git a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt index 44822056..5fb93940 100644 --- a/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt +++ b/samples/junit-tests/src/main/java/com/yelp/codegen/generatecodesamples/tools/XNullableAdapterFactory.kt @@ -38,12 +38,13 @@ class XNullableAdapterFactory : JsonAdapter.Factory { nextAdapter?.toJson(writer, value) } } + } } return null } - private fun Set.removeXNullableAnnotation(): MutableSet { + private fun Set.removeXNullableAnnotation():MutableSet{ return this.filter { it !is XNullable }.toMutableSet() } } diff --git a/samples/junit-tests/src/main/java/swagger.json b/samples/junit-tests/src/main/java/swagger.json index 795385d2..a76c0abc 100644 --- a/samples/junit-tests/src/main/java/swagger.json +++ b/samples/junit-tests/src/main/java/swagger.json @@ -1,908 +1 @@ -{ - "definitions": { - "empty_model": { - "type": "object", - "x-model": "empty_model" - }, - "format_responses": { - "properties": { - "date_property": { - "format": "date", - "type": "string" - }, - "datetime_property": { - "format": "date-time", - "type": "string" - }, - "enum_property": { - "enum": [ - "VALUE1", - "VALUE2" - ], - "type": "string" - } - }, - "type": "object", - "x-model": "format_responses" - }, - "nested_additional_properties": { - "additionalProperties": { - "$ref": "#/definitions/top_level_map" - }, - "type": "object", - "x-model": "nested_additional_properties" - }, - "nested_additional_properties_custom_description": { - "allOf": [ - { - "$ref": "#/definitions/nested_additional_properties" - }, - { - "description": "This is a workaroud to override the description provided by nested_additional_properties" - } - ], - "x-model": "nested_additional_properties_custom_description" - }, - "property_array": { - "properties": { - "number_array": { - "items": { - "type": "number" - }, - "type": "array" - }, - "string_array": { - "items": { - "type": "string" - }, - "type": "array" - } - }, - "type": "object", - "x-model": "property_array" - }, - "property_map": { - "properties": { - "number_map": { - "additionalProperties": { - "type": "number" - }, - "type": "object", - "x-model": "number_map" - }, - "object_map": { - "properties": {}, - "type": "object", - "x-model": "object_map" - }, - "string_map": { - "additionalProperties": { - "type": "string" - }, - "type": "object", - "x-model": "string_map" - } - }, - "type": "object", - "x-model": "property_map" - }, - "required_type_responses": { - "properties": { - "boolean_property": { - "type": "boolean" - }, - "enum_property": { - "enum": [ - "VALUE1", - "VALUE2" - ], - "type": "string" - }, - "integer_property": { - "type": "integer" - }, - "number_property": { - "type": "number" - }, - "string_property": { - "type": "string" - } - }, - "required": [ - "boolean_property", - "enum_property", - "integer_property", - "number_property", - "string_property" - ], - "type": "object", - "x-model": "required_type_responses" - }, - "reserved_keywords": { - "properties": { - "class": { - "type": "string" - }, - "for": { - "type": "string" - }, - "operator": { - "type": "string" - }, - "val": { - "type": "string" - }, - "var": { - "type": "string" - }, - "when": { - "type": "string" - } - }, - "type": "object", - "x-model": "reserved_keywords" - }, - "top_level_enum": { - "enum": [ - "TOP_LEVEL_VALUE1", - "TOP_LEVEL_VALUE2" - ], - "type": "string", - "x-model": "top_level_enum" - }, - "top_level_map": { - "additionalProperties": { - "type": "string" - }, - "type": "object", - "x-model": "top_level_map" - }, - "type_responses": { - "properties": { - "boolean_property": { - "type": "boolean" - }, - "integer_property": { - "type": "integer" - }, - "number_property": { - "type": "number" - }, - "string_property": { - "type": "string" - } - }, - "type": "object", - "x-model": "type_responses" - }, - "xnullable_format_responses": { - "properties": { - "date_property": { - "format": "date", - "type": "string", - "x-nullable": true - }, - "datetime_property": { - "format": "date-time", - "type": "string", - "x-nullable": true - }, - "double_property": { - "format": "double", - "type": "number", - "x-nullable": true - } - }, - "type": "object", - "x-model": "xnullable_format_responses" - }, - "xnullable_map": { - "additionalProperties": { - "type": "string", - "x-nullable": true - }, - "type": "object", - "x-model": "xnullable_map", - "x-nullable": true - }, - "xnullable_nested_additional_properties": { - "additionalProperties": { - "$ref": "#/definitions/xnullable_map" - }, - "type": "object", - "x-model": "xnullable_nested_additional_properties" - }, - "xnullable_property_array": { - "properties": { - "number_array": { - "items": { - "type": "number", - "x-nullable": true - }, - "type": "array", - "x-nullable": true - }, - "string_array": { - "items": { - "type": "string", - "x-nullable": true - }, - "type": "array", - "x-nullable": true - } - }, - "type": "object", - "x-model": "xnullable_property_array" - }, - "xnullable_property_map": { - "properties": { - "number_map": { - "additionalProperties": { - "type": "number", - "x-nullable": true - }, - "type": "object", - "x-model": "number_map", - "x-nullable": true - }, - "object_map": { - "properties": {}, - "type": "object", - "x-model": "object_map", - "x-nullable": true - }, - "string_map": { - "additionalProperties": { - "type": "string", - "x-nullable": true - }, - "type": "object", - "x-model": "string_map", - "x-nullable": true - } - }, - "type": "object", - "x-model": "xnullable_property_map" - }, - "xnullable_required_property_array": { - "properties": { - "number_array": { - "items": { - "type": "number", - "x-nullable": true - }, - "type": "array", - "x-nullable": true - }, - "string_array": { - "items": { - "type": "string", - "x-nullable": true - }, - "type": "array", - "x-nullable": true - } - }, - "required": [ - "number_array", - "string_array" - ], - "type": "object", - "x-model": "xnullable_required_property_array" - }, - "xnullable_required_property_map": { - "properties": { - "number_map": { - "additionalProperties": { - "type": "number", - "x-nullable": true - }, - "type": "object", - "x-model": "number_map", - "x-nullable": true - }, - "object_map": { - "properties": {}, - "type": "object", - "x-model": "object_map", - "x-nullable": true - }, - "string_map": { - "additionalProperties": { - "type": "string", - "x-nullable": true - }, - "type": "object", - "x-model": "string_map", - "x-nullable": true - } - }, - "required": [ - "number_map", - "object_map", - "string_map" - ], - "type": "object", - "x-model": "xnullable_required_property_map" - }, - "xnullable_required_type_responses": { - "properties": { - "boolean_property": { - "type": "boolean", - "x-nullable": true - }, - "enum_property": { - "enum": [ - "VALUE1", - "VALUE2" - ], - "type": "string", - "x-nullable": true - }, - "integer_property": { - "type": "integer", - "x-nullable": true - }, - "number_property": { - "type": "number", - "x-nullable": true - }, - "string_property": { - "type": "string", - "x-nullable": true - } - }, - "required": [ - "boolean_property", - "enum_property", - "integer_property", - "number_property", - "string_property" - ], - "type": "object", - "x-model": "xnullable_required_type_responses" - }, - "xnullable_type_responses": { - "properties": { - "boolean_property": { - "type": "boolean", - "x-nullable": true - }, - "enum_property": { - "enum": [ - "VALUE1", - "VALUE2" - ], - "type": "string", - "x-nullable": true - }, - "integer_property": { - "type": "integer", - "x-nullable": true - }, - "number_property": { - "type": "number", - "x-nullable": true - }, - "string_property": { - "type": "string", - "x-nullable": true - } - }, - "type": "object", - "x-model": "xnullable_type_responses" - } - }, - "info": { - "description": "This spec is used to have JUnit Tests to check the generated code.", - "title": "JUnit Tests", - "version": "1.1.0" - }, - "paths": { - "/empty_endpoint": { - "get": { - "operationId": "get_empty_endpoint", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/empty_model" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/format_endpoint/{property_format}": { - "get": { - "operationId": "get_format_endpoint", - "parameters": [ - { - "in": "path", - "name": "property_format", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/format_responses" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/nested_additional_properties": { - "get": { - "operationId": "get_nested_additional_properties", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/nested_additional_properties" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/nested_additional_properties/custom_description": { - "get": { - "operationId": "get_nested_additional_properties_custom_description", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/nested_additional_properties_custom_description" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/property_array/{value_type}/{size}": { - "get": { - "operationId": "get_property_array", - "parameters": [ - { - "in": "path", - "name": "value_type", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/property_array" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/property_map/{value_type}/{size}": { - "get": { - "operationId": "get_property_map", - "parameters": [ - { - "in": "path", - "name": "value_type", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/property_map" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/required/type_endpoint": { - "get": { - "operationId": "get_required_type_endpoint", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/required_type_responses" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/reserved_keywords": { - "get": { - "operationId": "get_reserved_keywords", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/reserved_keywords" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/symbols/in/parameter/name": { - "get": { - "description": "Make sure that symbols in parameter name are treated properly", - "operationId": "getSymbolsInParameterName", - "parameters": [ - { - "in": "query", - "name": "parameter", - "required": false, - "type": "string" - }, - { - "in": "query", - "name": "brackets[]", - "required": false, - "type": "string" - }, - { - "in": "query", - "name": "brackets[withText]", - "required": false, - "type": "string" - }, - { - "in": "query", - "name": "dot.", - "required": false, - "type": "string" - }, - { - "in": "query", - "name": "dot.withText", - "required": false, - "type": "string" - } - ], - "responses": { - "200": { - "description": "successful operation" - } - }, - "summary": "Test symbols in parameter name", - "tags": [ - "resource" - ] - } - }, - "/top_level_enum": { - "get": { - "operationId": "get_top_level_enum", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/top_level_enum" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/top_level_enum/nested": { - "get": { - "operationId": "get_top_level_enum_nested", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "additionalProperties": { - "additionalProperties": { - "$ref": "#/definitions/top_level_enum" - }, - "type": "object" - }, - "type": "object" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/top_level_map/{size}": { - "get": { - "operationId": "get_top_level_map", - "parameters": [ - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/top_level_map" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/type_endpoint/{property_type}": { - "get": { - "operationId": "get_type_endpoint", - "parameters": [ - { - "in": "path", - "name": "property_type", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/type_responses" - } - } - }, - "tags": [ - "resource" - ] - } - }, - "/xnullable/format_endpoint/{property_format}": { - "get": { - "operationId": "get_xnullable_format_endpoint", - "parameters": [ - { - "in": "path", - "name": "property_format", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_format_responses" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/nested_additional_properties": { - "get": { - "operationId": "get_xnullable_nested_additional_properties", - "parameters": [], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_nested_additional_properties" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/property_array/{value_type}/{size}": { - "get": { - "operationId": "get_xnullable_property_array", - "parameters": [ - { - "in": "path", - "name": "value_type", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_property_array" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/property_map/{value_type}/{size}": { - "get": { - "operationId": "get_xnullable_property_map", - "parameters": [ - { - "in": "path", - "name": "value_type", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_property_map" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/required/property_array/{size}": { - "get": { - "operationId": "get_xnullable_required_property_array", - "parameters": [ - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_required_property_array" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/required/property_map/{size}": { - "get": { - "operationId": "get_xnullable_required_property_map", - "parameters": [ - { - "in": "path", - "name": "size", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_required_property_map" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/required/type_endpoint/{property_type}": { - "get": { - "operationId": "get_xnullable_required_type_endpoint", - "parameters": [ - { - "in": "path", - "name": "property_type", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_required_type_responses" - } - } - }, - "tags": [ - "xnullable" - ] - } - }, - "/xnullable/type_endpoint/{property_type}": { - "get": { - "operationId": "get_xnullable_type_endpoint", - "parameters": [ - { - "in": "path", - "name": "property_type", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/xnullable_type_responses" - } - } - }, - "tags": [ - "xnullable" - ] - } - } - }, - "produces": [ - "application/json" - ], - "swagger": "2.0" -} +{"swagger":"2.0","info":{"description":"This spec is used to have JUnit Tests to check the generated code.","version":"1.1.0","title":"JUnit Tests"},"produces":["application/json"],"paths":{"/empty_endpoint":{"get":{"tags":["resource"],"operationId":"get_empty_endpoint","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/empty_model"}}}}},"/format_endpoint/{property_format}":{"get":{"tags":["resource"],"operationId":"get_format_endpoint","parameters":[{"name":"property_format","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/format_responses"}}}}},"/nested_additional_properties":{"get":{"tags":["resource"],"operationId":"get_nested_additional_properties","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/nested_additional_properties"}}}}},"/nested_additional_properties/custom_description":{"get":{"tags":["resource"],"operationId":"get_nested_additional_properties_custom_description","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/nested_additional_properties_custom_description"}}}}},"/property_array/{value_type}/{size}":{"get":{"tags":["resource"],"operationId":"get_property_array","parameters":[{"name":"value_type","in":"path","required":true,"type":"string"},{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/property_array"}}}}},"/property_map/{value_type}/{size}":{"get":{"tags":["resource"],"operationId":"get_property_map","parameters":[{"name":"value_type","in":"path","required":true,"type":"string"},{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/property_map"}}}}},"/required/type_endpoint":{"get":{"tags":["resource"],"operationId":"get_required_type_endpoint","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/required_type_responses"}}}}},"/reserved_keywords":{"get":{"tags":["resource"],"operationId":"get_reserved_keywords","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/reserved_keywords"}}}}},"/symbols/in/parameter/name":{"get":{"tags":["resource"],"summary":"Test symbols in parameter name","description":"Make sure that symbols in parameter name are treated properly","operationId":"getSymbolsInParameterName","parameters":[{"name":"parameter","in":"query","required":false,"type":"string"},{"name":"brackets[]","in":"query","required":false,"type":"string"},{"name":"brackets[withText]","in":"query","required":false,"type":"string"},{"name":"dot.","in":"query","required":false,"type":"string"},{"name":"dot.withText","in":"query","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation"}}}},"/top_level_enum":{"get":{"tags":["resource"],"operationId":"get_top_level_enum","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/top_level_enum"}}}}},"/top_level_enum/nested":{"get":{"tags":["resource"],"operationId":"get_top_level_enum_nested","parameters":[],"responses":{"200":{"description":"","schema":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/definitions/top_level_enum"}}}}}}},"/top_level_map/{size}":{"get":{"tags":["resource"],"operationId":"get_top_level_map","parameters":[{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/top_level_map"}}}}},"/type_endpoint/{property_type}":{"get":{"tags":["resource"],"operationId":"get_type_endpoint","parameters":[{"name":"property_type","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/type_responses"}}}}},"/xnullable/format_endpoint/{property_format}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_format_endpoint","parameters":[{"name":"property_format","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_format_responses"}}}}},"/xnullable/nested_additional_properties":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_nested_additional_properties","parameters":[],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_nested_additional_properties"}}}}},"/xnullable/property_array/{value_type}/{size}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_property_array","parameters":[{"name":"value_type","in":"path","required":true,"type":"string"},{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_property_array"}}}}},"/xnullable/property_map/{value_type}/{size}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_property_map","parameters":[{"name":"value_type","in":"path","required":true,"type":"string"},{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_property_map"}}}}},"/xnullable/required/property_array/{size}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_required_property_array","parameters":[{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_required_property_array"}}}}},"/xnullable/required/property_map/{size}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_required_property_map","parameters":[{"name":"size","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_required_property_map"}}}}},"/xnullable/required/type_endpoint/{property_type}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_required_type_endpoint","parameters":[{"name":"property_type","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_required_type_responses"}}}}},"/xnullable/type_endpoint/{property_type}":{"get":{"tags":["xnullable"],"operationId":"get_xnullable_type_endpoint","parameters":[{"name":"property_type","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/xnullable_type_responses"}}}}}},"definitions":{"empty_model":{"type":"object","x-model":"empty_model"},"format_responses":{"type":"object","properties":{"date_property":{"type":"string","format":"date"},"datetime_property":{"type":"string","format":"date-time"},"enum_property":{"type":"string","enum":["VALUE1","VALUE2"]}},"x-model":"format_responses"},"nested_additional_properties":{"type":"object","additionalProperties":{"$ref":"#/definitions/top_level_map"},"x-model":"nested_additional_properties"},"nested_additional_properties_custom_description":{"allOf":[{"$ref":"#/definitions/nested_additional_properties"},{"description":"This is a workaroud to override the description provided by nested_additional_properties"}],"x-model":"nested_additional_properties_custom_description"},"property_array":{"type":"object","properties":{"number_array":{"type":"array","items":{"type":"number"}},"string_array":{"type":"array","items":{"type":"string"}}},"x-model":"property_array"},"property_map":{"type":"object","properties":{"number_map":{"type":"object","additionalProperties":{"type":"number"},"x-model":"number_map"},"object_map":{"type":"object","properties":{},"x-model":"object_map"},"string_map":{"type":"object","additionalProperties":{"type":"string"},"x-model":"string_map"}},"x-model":"property_map"},"required_type_responses":{"type":"object","required":["boolean_property","enum_property","integer_property","number_property","string_property"],"properties":{"boolean_property":{"type":"boolean"},"enum_property":{"type":"string","enum":["VALUE1","VALUE2"]},"integer_property":{"type":"integer"},"number_property":{"type":"number"},"string_property":{"type":"string"}},"x-model":"required_type_responses"},"reserved_keywords":{"type":"object","properties":{"class":{"type":"string"},"for":{"type":"string"},"operator":{"type":"string"},"val":{"type":"string"},"var":{"type":"string"},"when":{"type":"string"}},"x-model":"reserved_keywords"},"top_level_enum":{"type":"string","enum":["TOP_LEVEL_VALUE1","TOP_LEVEL_VALUE2"],"x-model":"top_level_enum"},"top_level_map":{"type":"object","additionalProperties":{"type":"string"},"x-model":"top_level_map"},"type_responses":{"type":"object","properties":{"boolean_property":{"type":"boolean"},"integer_property":{"type":"integer"},"number_property":{"type":"number"},"string_property":{"type":"string"}},"x-model":"type_responses"},"xnullable_format_responses":{"type":"object","properties":{"date_property":{"type":"string","format":"date","x-nullable":true},"datetime_property":{"type":"string","format":"date-time","x-nullable":true},"double_property":{"type":"number","format":"double","x-nullable":true}},"x-model":"xnullable_format_responses"},"xnullable_map":{"type":"object","additionalProperties":{"type":"string","x-nullable":true},"x-model":"xnullable_map","x-nullable":true},"xnullable_nested_additional_properties":{"type":"object","additionalProperties":{"$ref":"#/definitions/xnullable_map"},"x-model":"xnullable_nested_additional_properties"},"xnullable_property_array":{"type":"object","properties":{"number_array":{"type":"array","items":{"type":"number","x-nullable":true},"x-nullable":true},"string_array":{"type":"array","items":{"type":"string","x-nullable":true},"x-nullable":true}},"x-model":"xnullable_property_array"},"xnullable_property_map":{"type":"object","properties":{"number_map":{"type":"object","additionalProperties":{"type":"number","x-nullable":true},"x-model":"number_map","x-nullable":true},"object_map":{"type":"object","properties":{},"x-model":"object_map","x-nullable":true},"string_map":{"type":"object","additionalProperties":{"type":"string","x-nullable":true},"x-model":"string_map","x-nullable":true}},"x-model":"xnullable_property_map"},"xnullable_required_property_array":{"type":"object","required":["number_array","string_array"],"properties":{"number_array":{"type":"array","items":{"type":"number","x-nullable":true},"x-nullable":true},"string_array":{"type":"array","items":{"type":"string","x-nullable":true},"x-nullable":true}},"x-model":"xnullable_required_property_array"},"xnullable_required_property_map":{"type":"object","required":["number_map","object_map","string_map"],"properties":{"number_map":{"type":"object","additionalProperties":{"type":"number","x-nullable":true},"x-model":"number_map","x-nullable":true},"object_map":{"type":"object","properties":{},"x-model":"object_map","x-nullable":true},"string_map":{"type":"object","additionalProperties":{"type":"string","x-nullable":true},"x-model":"string_map","x-nullable":true}},"x-model":"xnullable_required_property_map"},"xnullable_required_type_responses":{"type":"object","required":["boolean_property","enum_property","integer_property","number_property","string_property"],"properties":{"boolean_property":{"type":"boolean","x-nullable":true},"enum_property":{"type":"string","enum":["VALUE1","VALUE2"],"x-nullable":true},"integer_property":{"type":"integer","x-nullable":true},"number_property":{"type":"number","x-nullable":true},"string_property":{"type":"string","x-nullable":true}},"x-model":"xnullable_required_type_responses"},"xnullable_type_responses":{"type":"object","properties":{"boolean_property":{"type":"boolean","x-nullable":true},"enum_property":{"type":"string","enum":["VALUE1","VALUE2"],"x-nullable":true},"integer_property":{"type":"integer","x-nullable":true},"number_property":{"type":"number","x-nullable":true},"string_property":{"type":"string","x-nullable":true}},"x-model":"xnullable_type_responses"}}} \ No newline at end of file