OpenAPITools / OpenAPITools/openapi-generator

[BUG][rust-server] Regexes and validation are broken

Open
#18,204 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The rust-server generator uses the regex, validator and lazy_static crates. Since version 0.17.0 of validator, a breaking change was introduced that changed how to access regexes produced by regex and using lazy_static, as referred here: https://github.com/Keats/validator/issues/311#issuecomment-2013865902.

The generated code should be changed accordingly.

openapi-generator version

7.4.0

OpenAPI declaration file content or url

Unmodified petstore on openapi 3.0, available here: https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml

Generation Details

No special parameter or step is necessary.

Steps to reproduce
  • Generate a rust-server project using the petstore file.
  • Try to compile the generated project, an error will arise.
Related issues/PRs

https://github.com/Keats/validator/issues/311#issuecomment-2013865902

Suggest a fix

Two possible fixes:

  • Downgrade and pin validator to 0.16.1 (easy and fast but not ideal)
  • Fix the generated code (ideal solution but takes more time)

I will try to get a look at it.

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

Generate a rust-server project from the linked OpenAPI petstore specification, then compile it to reproduce the validator error. Inspect the generated validation code and its regex, validator, and lazy_static dependency declarations; done means the generated project compiles with validator 0.17.0 or later.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.