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

Snakecase fields in records should be turned into camelCase #17

Open
eeue56 opened this issue Jul 20, 2017 · 5 comments
Open

Snakecase fields in records should be turned into camelCase #17

eeue56 opened this issue Jul 20, 2017 · 5 comments

Comments

@eeue56
Copy link
Contributor

eeue56 commented Jul 20, 2017

Example input:

  Banana:
    type: object
    required:
      - banana_id
    properties:
      banana_id:
        type: string

right now generates:

type alias BananaRecord = 
  {  banana_id: String
  }

decodeBanana = ...
  ... 
  |> required "banana_id"
  ...

It should instead generate:

type alias BananaRecord = 
  {  bananaId: String
  }

decodeBanana = ...
  ... 
  |> required "banana_id"
  ...
@ahultgren
Copy link
Owner

I think this is a nice-to-have, since _, while not idiomatic, works. Also there's the issue of avoiding name collisions. Consider:

  Banana:
    type: object
    properties:
      banana_id:
        type: string
      bananaId:
        type: string

which would be valid swagger.

@eeue56
Copy link
Contributor Author

eeue56 commented Jul 20, 2017

I would argue that that example should actually be invalid swagger. If you have to things with the same name, the only difference being camelCase and camel_case, then you've duplicated the fields and made the API inconsistent

@ahultgren
Copy link
Owner

I agree it's a bad schema, but it's nonetheless a valid spec. Swagger is very unopinionated on how you name your fields. I suppose it's a separate issue though, since sanitization can already cause collisions.

@eeue56
Copy link
Contributor Author

eeue56 commented Jul 20, 2017

I would think the ideal approach would be to make swagger-elm warn you when your API contains underscores, and provide a flag for auto-converting it to camelCase

@ahultgren
Copy link
Owner

That sounds like a good solution

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