镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[JavaScript] CodeGen for Docs Camelizes Variables Without My Consent #6530

Open

Description

@brandonfuller
Description

We just found that our JavaScript docs being created by Swagger are incorrect. Our API takes variables like "grant_type" in the POST body. However, the SDK docs tell the user to use "grantType". We see that the Javascript CodeGen camelizes all the variables for the documentation, which confuses the dev reading the documentation.

Here is a sample documentation page:
https://github.com/bluejeans/api-rest-onvideo/blob/master/libs/javascript/docs/GrantRequestClient.md

Swagger-codegen version

2.2.3. Looks to have always been this way.

Swagger declaration file content or url
  GrantRequestClient:
    type: object
    properties:
      grant_type:
        type: string
        default: client_credentials
        description: The type of access token you are requesting.
      client_id:
        type: string
        description: The value given within the BlueJeans Enterprise Administration console.
      client_secret:
        type: string
        description: The value given within the BlueJeans Enterprise Administration console.
    required:
      - grant_type
      - client_id
      - client_secret
Command line used for generation

java -jar swagger-codegen-cli.jar generate -i ../swagger.yaml -l javascript -o ../libs/javascript --config config.javascript.json

Config just contains:

{
"moduleName":"X",
"projectName":"Y",
"projectDescription":"Z",
"projectLicenseName":"MIT",
"gitUserId":"A",
"gitRepoId":"B#npm-repo"
}

Steps to reproduce
  1. Generate code via command line
  2. View documentation file of a model that uses _ in a variable name
Related issues/PRs
Suggest a fix/enhancement

Can we stop camelizing variables in the docs that should not be modified?

Activity

  1. wing328 commented on Sep 24, 2017

    @wing328
    Contributor

    @brandonfuller Similar to Typescript, we can add an option to use the "original" name of the variable:

    	modelPropertyNaming
    	    Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name (Default: camelCase)
    

    Would you have time to add this feature to the JavaScript generator? If yes, I can show you some good starting points.

    cc @CodeNinjai @frol @cliffano

  2. added this to the v2.3.0 milestone on Sep 24, 2017
  3. modified the milestones: v2.3.0, v2.4.0 on Dec 15, 2017
  4. ishu-harsh commented on Feb 6, 2021

    @ishu-harsh

    It really saved my Job :)

  5. i-tabu commented on Feb 6, 2021

    @i-tabu

    Yes same here :)

  6. i-tabu commented on Feb 6, 2021

    @i-tabu

    I suggest that, it should be "original" by default. This is because a software should not impose naming convention (opinion). Because we had fallen into the same problem (even after the issue was solve in 2018) and solved it by searching the issues. If it would original by default then this problem would not have occurred again even after fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions