-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
NPE when responses are referenced from external yaml files #1155
Comments
Please provide the spec so that the community can more easily repeat the issue and help you out. |
Updated the issue with yaml content. When I remove the references to responses in the main yaml file, code-generation works fine |
👀 |
@srividhyak27 Thanks for the issue! openapi.yamlopenapi: 3.0.0
info:
title: Common Data Types
version: "1.0"
paths:
/{appId}/subscriptions:
get:
summary: read all of the active subscriptions for the app
responses:
'200':
description: OK (Successful)
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/subscription'
'400':
$ref: './common.yaml#/components/responses/E400'
'401':
$ref: './common.yaml#/components/responses/E401'
components:
schemas:
subscription:
type: string common.yamlopenapi: 3.0.0
info:
title: Common Data Types
version: "1.0"
paths: {}
components:
schemas:
ProblemDetails:
type: object
properties:
title:
type: string
description: A short, human-readable summary of the problem
status:
type: integer
description: The HTTP status code for this occurrence of the problem.
responses:
E400:
description: Bad request
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
E401:
description: Unauthorized
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
$ tree
.
├── common.yaml
└── openapi.yaml $ openapi-generator version
3.3.0 $ openapi-generator generate -g php -o /tmp/issue1155 -i openapi.yaml
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' not defined in the spec (2.0). Default to [http://localhost] for server URL [http://localhost/]
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' not defined in the spec (2.0). Default to [http://localhost] for server URL [http://localhost/]
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/Model/ProblemDetails.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/test/Model/ProblemDetailsTest.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/docs/Model/ProblemDetails.md
[main] WARN o.o.codegen.DefaultCodegen - Empty operationId found for path: get /{appId}/subscriptions. Renamed to auto-generated operationId: appIdSubscriptionsGet
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/Api/DefaultApi.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/test/Api/DefaultApiTest.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/docs/Api/DefaultApi.md
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' not defined in the spec (2.0). Default to [http://localhost] for server URL [http://localhost/]
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/ApiException.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/Configuration.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/ObjectSerializer.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/Model/ModelInterface.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/lib/HeaderSelector.php
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/composer.json
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/README.md
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/phpunit.xml.dist
[main] INFO o.o.codegen.DefaultGenerator - writing file /tmp/issue1155/.travis.yml
[main] INFO o.o.codegen.DefaultGenerator - writing file /tmp/issue1155/.php_cs
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/git_push.sh
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/.openapi-generator-ignore
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/issue1155/.openapi-generator/VERSION
$ |
I have the same problem in my project. Unfortunatelly I can't provide the code. But if I can help somehow with debug let me know. |
Ok so problem is with response like this:
edit:
this seems to be working for class generation, hovewer it's not valid |
Is there any update on this as me too facing similar issue. If the response tag in common.yaml is just below as mention , the issue still persists. Not sure why. Any Help? responses: |
One observation is that, if 'schemas' is referred from external file insted of 'responses', the code generation works. BELOW WORKS - 'schemas' referred externally instead of 'response'
$ tree |
Sorry for the late reply. The issue has fixed in latest version. Please give it a try with |
Please reopen this or report a new issue if still experiencing the issue. Thank you! |
@ackintosh Thanks for response. Yes the version v4.0.0-beta3 solved the issue. :) Also, please update me on the following issue . Cheers, |
Description
Exception in code-gen when responses are referenced from external yaml files
openapi-generator version
Same issue with 3.2.3 version as well.
OpenAPI declaration file content or url
In common.yaml, responses are defined
Command line used for generation
No
Steps to reproduce
mvn generate-sources
The text was updated successfully, but these errors were encountered: