Skip to content

[BUG] Protobuf Schema Codegen Incorrectly take Enums in Maps and Arrays as String for wrapComposedSchema #22383

@lucy66hw

Description

@lucy66hw

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

When generating Protobuf schemas for composed schemas that contain nested structures with enum references, the codegen incorrectly treats enums in maps and arrays as primitive string types, resulting in StringMap and StringArray wrappers instead of the correct enum-typed wrappers.

spec:

components:
  schemas:
    Fruit:
      type: string
      enum:
        - APPLE
        - BANANA
        - ORANGE
    
    FruitByColor:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/Fruit'
    
    FruitList:
      type: array
      items:
        $ref: '#/components/schemas/Fruit'
    
    FruitInventory:
      oneOf:
        - title: fruitList
          $ref: '#/components/schemas/FruitList'
        - title: fruitColor
          $ref: '#/components/schemas/FruitByColor'

protobuf:

enum Fruit {
  FRUIT_APPLE = 0;
  FRUIT_BANANA = 1;
  FRUIT_ORANGE = 2;
}
message FruitInventory {

  oneof fruit_inventory {

    StringArray fruit_list = 1;

    StringMap fruit_color = 2;

  }
}
  • A map containing enum values → should generate named enum map type (e.g., FruitMap)
  • An array containing enum items → should generate named enum array type (e.g., FruitArray)
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions