OpenAPITools / OpenAPITools/openapi-generator
[BUG] [rust-server] Operations are not generated when first tag is not sanitized
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Operations with more than one tag and a first tag that contains spaces (e.g. Tag 1) are not recognized by the rust-server generator.
openapi-generator version
I'm using 5eacc0d09f3, but the problem hasn't been fixed in master since then.
OpenAPI declaration file content or url
# spec.yml
openapi: "3.0.0"
info:
version: "1.0.0"
title: My API
tags:
- name: Tag 1
- name: Tag 2
paths:
/hello:
post:
tags: [Tag 1, Tag 2]
responses:
'200':
description: OK
Generation Details
openapi-generator-cli generate -g rust-server -i spec.yml
Steps to reproduce
- Create a
spec.ymlwith at least two tags, one of which has a space in it - Add an operation with 2 or more tags, the first of which is the one with a space
- Call the
rust-servergenerator
Related issues/PRs
It looks like this issue is caused by an incomplete fix for #312.
Suggest a fix
As far as I can tell, the issue is that the String tag passed into addOperationToGroup is sanitized, while the string returned by getName is not. This implies that only tags for which sanitizeTag is a NO-OP can pass the equality check in
The second check (co.tags.size() > 1) hides this bug for operations with a single tag. Since
uses sanitizeTag on the output of getName, the fix is probably to do the same in RustServerCodegen.addOperationToGroup
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
Inspect modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java at addOperationToGroup, then reproduce the issue with the supplied spec.yml and rust-server generation command. Done means operations whose first tag contains spaces are recognized and grouped correctly, consistently with the sanitization used by DefaultGenerator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, rust
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100