[BUG][Generator] Missing field for nested `allOf` when defined in intermediate properties
Created by: lwj5
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
Since ResourceAllOfNested
(refer to spec below) inherits all fields from ResourceBaseWithProp
, ResourceAllOfNested
MUST contain prop_field
. However, prop_field
is missing from the final output of ResourceAllOfNested
.
SwaggerUI correctly depicts the expected fields in ResourceAllOfNested
:
openapi-generator version
Not regression. Using latest
docker image built on 22 Aug 2021 (today).
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: NestedMissing
version: 0.0.1
servers:
- url: "http://localhost"
paths:
"/resource":
get:
operationId: getResource
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/ResourceAllOfNested"
components:
schemas:
ResourceBase:
type: object
properties:
name:
type: string
ResourceBaseWithProp:
type: object
allOf:
- $ref: "#/components/schemas/ResourceBase"
properties:
prop_field:
type: string
Other:
type: object
properties:
other:
type: string
ResourceAllOfNested:
type: object
allOf:
- $ref: "#/components/schemas/ResourceBaseWithProp"
- $ref: "#/components/schemas/Other"
Generation Details
go-server generation logs
[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: go-server (server)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'go-server' is considered stable.
[main] INFO o.o.c.languages.AbstractGoCodegen - Environment variable GO_POST_PROCESS_FILE not defined so Go code may not be properly formatted. To define it, try `export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"` (Linux/Mac)
[main] INFO o.o.c.languages.AbstractGoCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO o.o.codegen.utils.ModelUtils - [deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
[main] INFO o.o.codegen.utils.ModelUtils - [deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/model_other.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/model_resource_all_of_nested.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/model_resource_base.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/model_resource_base_with_prop.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/api_default.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/api_default_service.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/api/openapi.yaml
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/main.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/Dockerfile
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/go.mod
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/routers.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/logger.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/impl.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/helpers.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/api.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/openapi/error.go
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/README.md
[main] INFO o.o.codegen.TemplateManager - Skipped /tmp/openapi/generated/go-server/.openapi-generator-ignore (Skipped by supportingFiles options supplied by user.)
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/.openapi-generator/VERSION
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/go-server/.openapi-generator/FILES
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
typescript generation logs
[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: typescript (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'typescript' is considered experimental.
[main] WARN o.o.codegen.DefaultCodegen - The value (generator's option) must be either boolean or string. Default to `false`.
[main] WARN o.o.codegen.DefaultCodegen - The value (generator's option) must be either boolean or string. Default to `false`.
[main] INFO o.o.codegen.utils.ModelUtils - [deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
[main] INFO o.o.codegen.utils.ModelUtils - [deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/models/Other.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/models/ResourceAllOfNested.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/models/ResourceBase.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/models/ResourceBaseWithProp.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/apis/DefaultApi.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/DefaultApi.md
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/.gitignore
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/git_push.sh
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/util.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/apis/exception.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/http/http.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/servers.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/configuration.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/auth/auth.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/models/all.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/types/PromiseAPI.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/types/ObservableAPI.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/types/ObjectParamAPI.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/models/ObjectSerializer.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/middleware.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/apis/baseapi.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/index.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/http/isomorphic-fetch.ts
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/README.md
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/package.json
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/tsconfig.json
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/rxjsStub.ts
[main] INFO o.o.codegen.TemplateManager - Skipped /tmp/openapi/generated/ts-client/.openapi-generator-ignore (Skipped by supportingFiles options supplied by user.)
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/.openapi-generator/VERSION
[main] INFO o.o.codegen.TemplateManager - writing file /tmp/openapi/generated/ts-client/.openapi-generator/FILES
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
Steps to reproduce
Generate code using cli with any of the generators.
The following are two samples from go-server
and typescript
.
go-server
generator
type ResourceAllOfNested struct {
Name string `json:"name,omitempty"`
Other string `json:"other,omitempty"`
}
typescript
generator
export class ResourceAllOfNested {
'name'?: string;
'other'?: string;
static readonly discriminator: string | undefined = undefined;
Expected: both to contain prop_field
.
Related issues/PRs
None
Suggest a fix
Unsure