OpenAPITools / OpenAPITools/openapi-generator

[BUG] [rust-server] Operations are not generated when first tag is not sanitized

Open
#12,136 1 comment 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

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
  1. Create a spec.yml with at least two tags, one of which has a space in it
  2. Add an operation with 2 or more tags, the first of which is the one with a space
  3. Call the rust-server generator
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

https://github.com/OpenAPITools/openapi-generator/blob/edfb3e123f0d3ad48992e158da957e87c3b8c3fe/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java#L1112

The second check (co.tags.size() > 1) hides this bug for operations with a single tag. Since

https://github.com/OpenAPITools/openapi-generator/blob/edfb3e123f0d3ad48992e158da957e87c3b8c3fe/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L1134

uses sanitizeTag on the output of getName, the fix is probably to do the same in RustServerCodegen.addOperationToGroup

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.