-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DefaultGenerator] NullPointerException on code generation #855
Comments
Thank you for this issue. Your spec is almost 10500 lines. Having a minimal example to reproduce the issue would help. Have you tried with the latest version |
For what it's worth, with version 3.1.0 of the code, the stack trace says line 3005
|
Just debugged the issue, it's coming from some header definitions, at least I could reproduce the issue on branch
|
Reproduced with: openapi: 3.0.1
info:
title: Issue 855 example
version: 1.0.0
components:
headers:
X-Request-ID:
description: ID of the request, unique to the call, as determined by the initiating party.
required: true
example: "99391c7e-ad88-49ec-a2ad-99ddcb1f7721"
schema:
type: string
format: uuid
responses:
OK_200:
description: OK
headers:
X-Request-ID:
$ref: "#/components/headers/X-Request-ID"
paths:
/ping:
get:
summary: Get Payment Information
description: Returns the content of a payment object
responses:
'200':
$ref: "#/components/responses/OK_200" Referenced Header are not supported. We need to support this OAS3 feature. Work around: openapi: 3.0.1
info:
title: Issue 855 example
version: 1.0.0
components:
responses:
OK_200:
description: OK
headers:
X-Request-ID:
description: ID of the request, unique to the call, as determined by the initiating party.
required: true
example: "99391c7e-ad88-49ec-a2ad-99ddcb1f7721"
schema:
type: string
format: uuid
paths:
/ping:
get:
summary: Get Payment Information
description: Returns the content of a payment object
responses:
'200':
$ref: "#/components/responses/OK_200" Do you want to propose a fix for this? In ModelUtils 2 methods are requested:
They need to be called, at least at the point where there is a NPE. You will also need to add the OpenAPI instance as parameter of some methods in DefaultGenerator. I can also have a look, but I have limited time. |
@jmini I'm looking into it :-) |
With #863 merged this should be fixed, don't think it will make it into the 3.2.2 release though |
@rienafairefr thanks, did u run the full yaml by any chance? |
Yep, I tried with generator |
@hl191 Please try with |
Thanks, the NullPointer is gone. There are some generated classes without member variables when using the full yaml. I will evaluate the created model and file another issue eventually. |
Thank you for the feedback. Please feel free to open other issues if requested. |
When in responses using headers 401:
description: klicatelj nima vloge upravitelj za osebni paket ali delo z
organizacijo
headers:
reason:
description: basic description what was wrong
style: simple
code:
description: error code of what was wrong
style: simple
env:
error:
|
@sysmat Your problem is that you do not have a Schema defined in your header. It works when you write: paths:
/ping:
get:
operationId: pingGet
responses:
'201':
description: OK
headers:
x-app-reason:
description: basic description what was wrong
style: simple
schema:
type: string
x-app-error-code:
description: error code of what was wrong
style: simple
schema:
type: string I have proposed an PR to use String when nothing is defined. See #2133. Fell free to continue the discussion there. |
@sysmat you can try with the latest |
Description
Generating Code for yaml produces Nullpoint exception
Tried inlining/modifying headers and responses with description.
openapi-generator version
openapi-generator-maven-plugin
version 3.1.0/3.2.0
generator: jaxrs-spec
OpenAPI declaration file content or url
https://berlingroup.stackstorage.com/s/d4KSrRW9bDYmrSg
Steps to reproduce
Use openapi-generator-maven-plugin to generate sources from given OpenAPI spec.
Suggest a fix/enhancement
Investigating NullPointerException
The text was updated successfully, but these errors were encountered: