OpenAPITools / OpenAPITools/openapi-generator
[BUG][Elm] use of pattern generates encoder that doesn't parse
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
Description
Given the schema below, see that Elm generator has wrong behavior.
openapi-generator version
5.0.0 branch, 4th Feb 2020
OpenAPI declaration file content or url
uuid4:
type: string
# Taken from https://stackoverflow.com/a/38191078/133235
pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[4][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'
Command line used for generation
openapi-generator-cli generate --input-spec openapi.yaml --enable-post-process-file --generator-name elm --config openapi-generator.yml --output openapi-client
Steps to reproduce
Generates encodeUuid4Pairs with a syntax error:
encodeUuid4 : Uuid4 -> Json.Encode.Value
encodeUuid4 =
encodeObject << encodeUuid4Pairs
encodeUuid4WithTag : ( String, String ) -> Uuid4 -> Json.Encode.Value
encodeUuid4WithTag (tagField, tag) model =
encodeObject (encodeUuid4Pairs model ++ [ encode tagField Json.Encode.string tag ])
encodeUuid4Pairs : Uuid4 -> List EncodedField
encodeUuid4Pairs model =
let
pairs =
]
in
pairs
cc @eriktim
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 reproducing the issue with the supplied OpenAPI declaration and the openapi-generator-cli command using the elm generator. Inspect the generated encodeUuid4Pairs output and verify that the generated Elm is syntactically valid and can parse the pattern-based schema without the stray closing bracket.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elm, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100