Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13161
Closed
Open
Issue created Aug 11, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [AVRO-schema] no modelPackage prefix on arrays with items having a $ref to a predefined enum

Created by: aghajani

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

When an enum is defined to be used later on multiple places using ref, and it is used in an array items, the output will miss modelPackage prefix (packageName). See samples below for better understanding.

openapi-generator version

6.1.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Core basic events schema
  description: |
    Specification for all the basic events in core
  version: 1.1.0
servers: []
paths: {}

components:
  schemas:
    ApiResponseStatuses:
      type: string
      enum:
        - success
        - failure
        - timeout
    ApiResponse:
      title: An uploaded response
      description: Describes the result of uploading an image resource
      type: object
      properties:
        code:
          type: integer
          format: int32
        type:
          type: string
        message:
          type: string
        statuses:
          type: array
          items:
            $ref: '#/components/schemas/ApiResponseStatuses'
Generation Details

Current output:

{
  "namespace": "model",
  "type": "record",
  "doc": "Describes the result of uploading an image resource",
  "name": "ApiResponse",
  "fields": [
    {
      "name": "code",
      "type": ["null", "int"],
      "doc": "",
      "default": null
    },
    {
      "name": "type",
      "type": ["null", "string"],
      "doc": "",
      "default": null
    },
    {
      "name": "message",
      "type": ["null", "string"],
      "doc": "",
      "default": null
    },
    {
      "name": "statuses",
      "type": ["null", {
        "type": "array",
        "items": "ApiResponseStatuses"
      }],
      "doc": "",
      "default": null
    }
  ]
}

Expected output (partially):

{
    {
      "name": "statuses",
      "type": ["null", {
        "type": "array",
        // BELOW LINE
        "items": "model.ApiResponseStatuses"
      }],
      "doc": "",
      "default": null
    }
}
Suggest a fix

The fix should be as simple as changing the mustache template for modules/openapi-generator/src/main/resources/avro-schema/typeArray.mustache

Assignee
Assign to
Time tracking