Yelp / swagger-gradle-codegen

💫 A Gradle Plugin to generate your networking code from Swagger
Apache License 2.0
412 stars 37 forks source link

`data` become `data` in generated code #147

Closed klaszlo8207 closed 3 years ago

klaszlo8207 commented 3 years ago

please replace &#x60 to `

cortinico commented 3 years ago

Hey @klaszlo8207 I'm sorry but the information you provide is too little to help me even understand what the issue is about. Can you provide a sample Swagger file and a snippet of how the generated code looks like?

klaszlo8207 commented 3 years ago

sample:

good code:

    @POST("signin")
    suspend fun SigninUsingPOST( @retrofit2.http.Body `data`: SigninRequest): SignInResponse

generated code:

    @POST("signin")
    suspend fun SigninUsingPOST( @retrofit2.http.Body &#x60data&#x60: SigninRequest): SignInResponse
cortinico commented 3 years ago

Can you provide also your Swagger file (or the fragment that generated this code)?

klaszlo8207 commented 3 years ago

Sorry it is a private swagger

cortinico commented 3 years ago

Sorry it is a private swagger

Can I ask you to create a reproducer (i.e. extract only the fields that are producing the problem and redact the names if needed).

macisamuele commented 3 years ago

echoing @cortinico here ... having a sample spec that is able to trigger the issue helps us more to identify the bug, ensure that it get fixed and have a test that ensures that no regressions would be present in upcoming releases.

Still by trying to create specs that would create such type of API seems that something like the following might represent a minimal spec

swagger: '2.0'
info:
  title: Reproduce https://github.com/Yelp/swagger-gradle-codegen/issues/147
  version: 0.0.0
paths:
  /signin:
    post:
      operationId: SigninUsingPOST
      parameters:
        - in: body
          name: data
          schema:
            type: object
            x-model: SigninRequest
            properties:
              p:
                type: integer
          required: true
      responses:
        default:
          description: ''
          schema:
            type: object
            properties:
              p:
                type: string
            x-model: SignInResponse

as it would generate (with the kotlin generator) the following API file

/**
 * NOTE: This class is auto generated by the Swagger Gradle Codegen for the following API: JUnit Tests
 *
 * More info on this tool is available on https://github.com/Yelp/swagger-gradle-codegen
 */

package com.yelp.codegen.generatecodesamples.apis

import com.yelp.codegen.generatecodesamples.models.SignInResponse
import com.yelp.codegen.generatecodesamples.models.SigninRequest
import io.reactivex.Single
import retrofit2.http.Headers
import retrofit2.http.POST

@JvmSuppressWildcards
interface DefaultApi {
    /**
     * The endpoint is owned by junittests service owner
     * @param `data` (required)
     */
    @Headers(
        "X-Operation-ID: SigninUsingPOST"
    )
    @POST("/signin")
    fun signinUsingPOST(
        @retrofit2.http.Body `data`: SigninRequest
    ): Single<SignInResponse>
}
klaszlo8207 commented 3 years ago

Is it now fixed? Can I use the new code somehow from maven new version? 1.4.2?

cortinico commented 3 years ago

It's fixed but will be available in the upcoming version 👍

klaszlo8207 commented 3 years ago

It's fixed but will be available in the upcoming version 👍

When will be this available? Thanks

cortinico commented 3 years ago

When will be this available? Thanks

We can't really commit on a timeline, but I'm getting @macisamuele onboard to finalize 2.0.0. Ideally we should merge those PRs first #110 #114 #104 (there might be a couple more).