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

[BUG][GO] Missing vendor extensions in inlined objects

Created by: mcdoker18

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

Initially, I found that custom Golang tags are not created for inlined objects. I use the x-go-custom-tag vendor extension for the tags. But after some investigation in the source code, I found that InlineModelResolver doesn't copy vendor extensions, description, and a couple of other options from an inlined object to a new one.

openapi-generator version

The issue reproduces in both 4.3.1 and 5.0.0-beta3 versions.

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  version: "1.0.0"
  title: Test
paths:
  /config:
    get:
      tags:
        - test
      description: ""
      responses:
        '200':
          description: ""
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Entity'
components:
  schemas:
    Entity:
      type: object
      properties:
        string_field:
          x-go-custom-tag:
            - 'test:"true"'
          type: string
        object_field:
          x-go-custom-tag:
            - 'test:"true"'
          type: object
          properties:
            string_field:
              x-go-custom-tag:
                - 'test:"true"'
              type: string
        allOf_field:
          allOf:
            - $ref: "#/components/schemas/Entity2"
            - type: object
              x-go-custom-tag:
                - 'test:"true"'
        array_field:
          x-go-custom-tag:
            - 'test:"true"'
          type: array
          items:
            type: string
    Entity2:
      type: object
      properties:
        string_field:
          x-go-custom-tag:
            - 'test:"true"'
          type: string
Steps to reproduce
openapi-generator generate -g go -o output/go/ -i output/test.yaml --git-host=test --git-user-id=test --global-property models,debugModels=true --additional-properties=isGoSubmodule=false,packageName=dto,generateInterfaces=true,useOneOfDiscriminatorLookup=true,enumClassPrefix=true

Actual:

type Entity struct {
       //...
	ObjectField *EntityObjectField `json:"object_field,omitempty"`
       //...
}

Expected:

type Entity struct {
       //...
	ObjectField *EntityObjectField `json:"object_field,omitempty" test:"true"`
       //...
}
Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/1125

Suggest a fix

If you confirm this bug, I'd like to push my fix.

Assignee
Assign to
Time tracking