swagger-api / swagger-api/swagger-codegen

[Java] need apply toRegularExpression method for pattern from string model

Open
#9,486 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/swagger-api/swagger-codegen/blob/79e800ae82555db95b21ff49b01f8e6595326598/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java#L3184

Otherwise, for the generated model for Spring, the annotation contains an incorrect regexp.
example: @Pattern(regexp="^\d{4}$")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java at line 3184 and inspect how the pattern string is handled for generated Spring models. Check the generated @Pattern annotation using the provided regexp example, and consider the work complete when the annotation contains the correctly transformed regular expression.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.