Description
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
openapi-generator version
We are using gradle plugin version 7.1.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
description: apis
version: 1.0.0
title: debug-apis
paths:
/stream:
get:
summary: Get the notifications stream
operationId: getNotificationsStream
responses:
"200":
$ref: "#/components/responses/NotificationStream"
components:
schemas:
Notification:
type: object
properties:
message:
type: string
NotificationArray:
type: array
format: event-stream
items:
$ref: '#/components/schemas/Notification'
responses:
NotificationStream:
description: notification stream
content:
text/event-stream:
schema:
$ref: '#/components/schemas/NotificationArray'
Generation Details
The configuration file used, you can make the generation work by changing serverSentEvents
from true
to false
.
{
"library": "spring-boot",
"apiPackage": "com.example.api",
"invokerPackage": "com.example.invoker",
"modelPackage": "com.example.model",
"hideGenerationTimestamp": "true",
"generatePom": "false",
"title": "debug-title",
"interfaceOnly": "true",
"serverSentEvents": "true",
"delegatePattern": "true",
"reactive": "true",
"unhandledException": "true",
"dateLibrary": "java8",
"useSpringBoot3": "true"
}
Steps to reproduce
See #17273 for test use case failing
Schemas leading to issue
The schema above produces
Exception: element cannot be mapped to a null key
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1269)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1160)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:609)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:994)
at org.openapitools.generator.gradle.plugin.tasks.GenerateTask.doWork(GenerateTask.kt:925)
... 122 more
Caused by: java.lang.NullPointerException: element cannot be mapped to a null key
at org.openapitools.codegen.languages.SpringCodegen.fromOperation(SpringCodegen.java:1288)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1237)
... 126 more
Related issues/PRs
Suggest a fix
If we place the schema definition directly in the response it works.
....
responses:
NotificationStream:
description: notification stream
content:
text/event-stream:
schema:
type: array
format: event-stream
items:
$ref: '#/components/schemas/Notification'