[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.