[BUG] NPE when validating schema with allOf with inline values
Created by: rasmusfaber
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output?
Description
Using a schema with an allOf with an inline object, i.e.
components:
schemas:
allOfInline:
allOf:
- type: object
properties:
name:
type: string
causes the validator (with recommend, which is default with the Maven job) to fail with a NullPointerException:
java.lang.NullPointerException: element cannot be mapped to a null key at java.util.Objects.requireNonNull (Objects.java:246) at java.util.stream.Collectors.lambda$groupingBy$53 (Collectors.java:1127) at java.util.stream.ReduceOps$3ReducingSink.accept (ReduceOps.java:169) at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:177) at java.util.Iterator.forEachRemaining (Iterator.java:133) at java.util.Spliterators$IteratorSpliterator.forEachRemaining (Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:484) at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:913) at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:578) at org.openapitools.codegen.utils.ModelUtils.getChildrenMap (ModelUtils.java:880) at org.openapitools.codegen.utils.ModelUtils.getUnusedSchemas (ModelUtils.java:120) at org.openapitools.codegen.config.CodegenConfigurator.toContext (CodegenConfigurator.java:462) at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput (CodegenConfigurator.java:498) at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:705)
openapi-generator version
4.2.2
OpenAPI declaration file content or url
openapi: 3.0.1
info:
version: 1.0.0
title: Example
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/person:
get:
operationId: list
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/allOfInline"
components:
schemas:
allOfInline:
allOf:
- type: object
properties:
name:
type: string
Command line used for generation
java -jar openapi-generator-cli.jar validate -i allOf-inline.yaml --recommend
(or use Maven)
Steps to reproduce
Execute command as above
Related issues/PRs
Regression was introduced in 10627ed5 during the fix of #4335
Suggest a fix
PR incoming