swagger-api / swagger-api/swagger-codegen
[ELM] Functions generated from operationId can have invalid names
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The operationId field of paths can have values which are not valid Elm identifiers. It seems that these values are used unmodified to produce Elm function names, meaning that the generator produces invalid Elm code.
This happens, for example, when operationId values contain "."s, as is common when using connexion.
Swagger-codegen version
2.4.17
Swagger declaration file content or url
basePath: /
consumes:
- application/json
info:
description: An API
title: An API
version: '1.0'
paths:
/:
get:
operationId: get.foo.bar
responses:
'200':
description: Success
produces:
- application/json
swagger: '2.0'
Command line used for generation
swagger-codegen generate -i broken.yaml -l elm -o gen
Steps to reproduce
- Put the above YAML into
broken.yaml - Run the command above
Suggest a fix/enhancement
At least for my purposes, replacing '.' with '_' in the function names would do the trick. There may be more characters in valid operationId's which are invalid in Elm identifiers, though, so someone who knows the spec should find all translations that need to happen.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided broken.yaml declaration with swagger-codegen generate -i broken.yaml -l elm -o gen, then inspect the generated Elm function name for get.foo.bar. Trace how operationId values reach the Elm output and account for invalid identifier characters; done means the generated code is valid Elm for this example and other invalid operationId values are handled consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elm
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100