Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data become `data` in generated code #147

Closed
klaszlo8207 opened this issue Jan 12, 2021 · 10 comments · Fixed by #148
Closed

data become `data` in generated code #147

klaszlo8207 opened this issue Jan 12, 2021 · 10 comments · Fixed by #148

Comments

@klaszlo8207
Copy link

klaszlo8207 commented Jan 12, 2021

please replace &#x60 to `

@cortinico
Copy link
Collaborator

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
Copy link
Author

klaszlo8207 commented Jan 14, 2021

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
Copy link
Collaborator

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

@klaszlo8207
Copy link
Author

Sorry it is a private swagger

@cortinico
Copy link
Collaborator

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
Copy link
Collaborator

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>
}

macisamuele added a commit to macisamuele/swagger-gradle-codegen that referenced this issue Jan 16, 2021
…ters name are properly escaped

This commit addresses Yelp#147
macisamuele added a commit to macisamuele/swagger-gradle-codegen that referenced this issue Jan 16, 2021
…ters name are properly escaped

This commit addresses Yelp#147

Co-authored-by: Nicola Corti <[email protected]>
@klaszlo8207
Copy link
Author

klaszlo8207 commented Jan 26, 2021

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

@cortinico
Copy link
Collaborator

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

@klaszlo8207
Copy link
Author

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

When will be this available? Thanks

@cortinico
Copy link
Collaborator

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants