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

If my response has a key with a hyphen character, swagger generates properties with invalid identifiers #503

Closed
jiridanek opened this issue Mar 14, 2015 · 2 comments

Comments

@jiridanek
Copy link

My schema:

    /users/show:
        get:
        parameters:
            - name: username
            in: query
            description: Username of the user.
            required: true
            type: string
        responses:
            200:
            schema:
                $ref: '#/definitions/User'

    definitions:
      User:
        properties:
        "change-design":
            type: boolean

Then in the generated binding code I see definitions like

./main/java/io/swagger/client/model/User.java:  public void setChange-design(Boolean change-design) {

That is, there is a hyphen. Hyphen is not a valid character in identifiers in most programming languages. As far as I know, hyphen works only in lisps.

I tested this with Python, Java and Scala codegen. Happens in all those languages. I suggest that the specification should be amended with a new property that would allow me to specify a new name for the parameter using only A-Za.z_ characters.

fehguy added a commit that referenced this issue Mar 17, 2015
@fehguy
Copy link
Contributor

fehguy commented Mar 17, 2015

The pattern for fixing this is has been committed for java. It needs to be applied to other languages, and in broader context.

cchafer added a commit to cchafer/swagger-codegen that referenced this issue Mar 17, 2015
* commit 'c96853d5aaaae3da6b40f7a204ed76faf1e7a05a':
  fix and tests for swagger-api#503
  removed unnecessary file
  removed description
  fixed context path
  added context path
  added more helpful error trace
  Adding defintion of security schemes in CodegenSecurity
  add ruby codegen, update sample (petstore) for ruby
  update php to support user agent
cchafer added a commit to cchafer/swagger-codegen that referenced this issue Mar 17, 2015
* develop_2.0:
  fix and tests for swagger-api#503
  removed unnecessary file
  removed description
  fixed context path
  added context path
  added more helpful error trace
  Adding defintion of security schemes in CodegenSecurity
  Adding defintion of security schemes in CodegenSecurity
  add ruby codegen, update sample (petstore) for ruby
  update php to support user agent

Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenSecurity.java
@fehguy fehguy closed this as completed Apr 4, 2015
@jiridanek
Copy link
Author

I guess replacing the hyphen with an underscore is good too. ;)

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

No branches or pull requests

2 participants