Bug Report Checklist
Description
From version 7.3.0 when referencing two models using the oneOf keyword and:
- the first model has a required and defined property named
property1 and
- the second model is a combined model using the
allOf keyword
we get this unexpected error in the logs:
[main] ERROR o.o.codegen.DefaultCodegen - Required var property1 not in properties
[main] ERROR o.o.codegen.DefaultCodegen - Required var property1 not in properties
Although we get this error, the generator doesn't exit and generates the api code.
We also see this error in the logs, when building the project from master following these https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator instructions. Here is one of the logs:
...
[TestNG-test=Surefire test-3] ERROR org.openapitools.codegen.DefaultCodegen - Required var seeds not in properties
...
openapi-generator version
version 7.3.0
OpenAPI declaration file content or url
Here is the minimal yaml file that produces the above errors:
openapi: 3.0.3
info:
title: Test
version: 1.0.0
paths:
/api/v1/user:
get:
operationId: getUser
responses:
'200':
description: Successfully fetched information for the user
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/UserInfoPhone'
- $ref: '#/components/schemas/UserInfoEmail'
'401':
description: Failed to authenticate request
components:
schemas:
User:
type: object
properties:
name:
type: string
surname:
type: string
UserInfoEmail:
allOf:
- $ref: '#/components/schemas/User'
- type: object
properties:
email:
type: string
UserInfoPhone:
type: object
required:
- phone
properties:
phone:
type: string
Generation Details
Steps to reproduce
To reproduce the errors, you can run:
openapi-generator-cli generate -i test.yaml -g typescript-axios
where test.yaml contains the above script.
The errors we get when generating the code are:
[main] ERROR o.o.codegen.DefaultCodegen - Required var phone not in properties
[main] ERROR o.o.codegen.DefaultCodegen - Required var phone not in properties
Related issues/PRs
No related PRs/issues found.
Suggest a fix
The above error log is introduced by this commit 64f2cad.
We noticed that we don't get the error if we use one of the following options:
- we reverse the order we reference the components in the
oneOf keyword
- we don't use the
allOf keyword to extend a model (e.g. in the above example define the properties of the User model directly on the UserInfoEmail model)
- we use the
--openapi-normalizer REF_AS_PARENT_IN_ALLOF=true argument when generating the code.
Bug Report Checklist
Description
From version
7.3.0when referencing two models using theoneOfkeyword and:property1andallOfkeywordwe get this unexpected error in the logs:
Although we get this error, the generator doesn't exit and generates the api code.
We also see this error in the logs, when building the project from master following these https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator instructions. Here is one of the logs:
openapi-generator version
version
7.3.0OpenAPI declaration file content or url
Here is the minimal
yamlfile that produces the above errors:Generation Details
Steps to reproduce
To reproduce the errors, you can run:
where
test.yamlcontains the above script.The errors we get when generating the code are:
Related issues/PRs
No related PRs/issues found.
Suggest a fix
The above error log is introduced by this commit 64f2cad.
We noticed that we don't get the error if we use one of the following options:
oneOfkeywordallOfkeyword to extend a model (e.g. in the above example define the properties of theUsermodel directly on theUserInfoEmailmodel)--openapi-normalizer REF_AS_PARENT_IN_ALLOF=trueargument when generating the code.