-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
I found a bug when generating api for a service responsing with an array of objects. Generated code doesn't point to proper class definition (TestObject in the example below replaced with Any?) despite it was properly generated.
Input:
{
"swagger": "2.0",
"info": {
"version": "1.0",
"title": "test-swagger",
"description": "https://test-swagger.com/"
},
"schemes": [
"https",
"http"
],
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"paths": {
"/api/test/swagger": {
"get": {
"tags": [
"test-swagger"
],
"summary": "Test swagger.",
"parameters": [
{
"name": "id",
"in": "query",
"required": true,
"description": "Uniqe id.",
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"properties": {
"cities": {
"type": "array",
"items": {
"$ref": "#/definitions/TestObject"
}
}
}
}
}
}
}
}
},
"definitions": {
"TestObject": {
"properties": {
"name": {
"type": "string"
}
}
}
}
}
Output:
package com.test.package.apis
import com.test.package.models.Any?
import retrofit2.http.GET
import retrofit2.http.Headers
@JvmSuppressWildcards
interface TestSwaggerApi {
/**
* Test swagger.
* The endpoint is owned by defaultname service owner
* @param id Uniqe id. (required)
*/
@Headers(
"Content-Type: application/json"
)
@GET("/api/test/swagger")
suspend fun apiTestSwaggerGet(
@retrofit2.http.Query("id") id: String
): Map<String, Any?>
}
package com.test.package.models
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* @property name
*/
@JsonClass(generateAdapter = true)
data class TestObject(
@Json(name = "name") @field:Json(name = "name") var name: String? = null
)
Metadata
Metadata
Assignees
Labels
No labels