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
  • #11200
Closed
Open
Issue created Dec 30, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] empty type property on referenced enums

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, the output Avro schema will put empty value on type property attribute of ref property. See samples below for better understanding.

openapi-generator version

lateset build from master and release: 5.3.1

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Money event schema
  description: |
    Specification for the the MoneyEvent and all subtypes
  version: 0.1.0
servers: []
paths: {}

components:
  schemas:
    MoneyEventType:
      description: 'The kind of monetary transaction'
      type: string
      enum:
        - x1
        - x2

    MoneyEvent:
      description: 'A event describing some kind of monetary transaction'
      required:
        - eventType
      properties:
        eventType:
          $ref: '#/components/schemas/MoneyEventType'
Generation Details

generating models is enough to see invalid output for MoneyEvent:

{
  "namespace": "models",
  "type": "record",
  "doc": "A event describing some kind of monetary transaction",
  "name": "MoneyEvent",
  "fields": [
    {
      "name": "eventType",
      "type": ,
      "doc": ""
    }
  ]
}
Suggest a fix

The fix should be as simple as changing the mustache template for typeProperty in avro

Assignee
Assign to
Time tracking