OpenAPITools / OpenAPITools/openapi-generator

[BUG][go-server] Repeated letters like GGG are generated like Ggg

Open
#15,055 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

Generating repeated letters like GGG, are sometimes (this time, specifically in enum) generated as Ggg which should same model name and method name
more in detail, please see below↓

Actual result
in reference repo (see below (Shift+g)), function AssertGggScopeEnumRequired in generated/go/model_ggg_scope_enum.go has its Ggg characters,
but function line:29 AssertGGGScopeEnumRequired in generated/go/model_patch_users_user_id_request.go has its GGG, which is all uppercase.

Expected result
I expect they have same function name like AssertGggScopeEnumRequired

Note: that we can use oneOf instead of using allOf, but it make them completely different name so I might like to use allOf for this time. anyOf also generate similar (or same?) function name as like oneOf do.

openapi-generator version

We are using v6.0.1 - in docker

OpenAPI declaration file content or url

It's long, so I'd paste gist here:
https://gist.github.com/rikusen0335/afe53b2c9b16dee83103199a2808fdea

Generation Details
  • golang 1.20 (in local. docker image uses 1.10)
  • go-server
  • configs:
    • only featureCORS: true
Steps to reproduce
version: '3.5'

services:
  api:
    image: openapitools/openapi-generator-cli:v6.0.1
    volumes:
      - .:/work
    working_dir: /work
    command: >
      sh -c '
        rm -rf /work/generated/*
        docker-entrypoint.sh generate \
        --generator-name go-server \
        --input-spec /work/test.yaml \
        --config /work/config.yaml \
        --output /work/generated \
        --additional-properties enumClassPrefix=true
      '
  1. Just copy and run above as docker compose
Related issues/PRs

No issues found if didn't I miss something

Suggest a fix

Other models like GGGDeveloper in model is named as GggDeveloper, so it might be name like GggScopeEnum.

Reference

This repo might help and won't waste your time:
https://github.com/rikusen0335/reproduce-openapi-goserver-repeted-letters-bug/blob/main/test.yaml

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 with the linked test.yaml and config.yaml, then run the provided Docker Compose go-server generation command. Compare generated/go/model_ggg_scope_enum.go with generated/go/model_patch_users_user_id_request.go, focusing on AssertGggScopeEnumRequired versus AssertGGGScopeEnumRequired. Done means the repeated-letter name is generated consistently as AssertGggScopeEnumRequired.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.