Open Xavientois opened 2 years ago
Same issue here
I got the same issue (tested on v5.4.0, 6.0.0-beta and 4.3.1).
This is due to having a "type": "array" property without specifying the "items" schema for this property.
So the schema is indeed wrong but the error is misleading.
I'm seeing this as well, and my type is an object, not an array, as it is for the OP ("The type is not array, so I do not understand why it claims it is missing")
It was happening to me as well... the only thing I found out is that it is only happening when you have an array within the object causing the issue. As in the example above, the Config
object has a property called myProperty
which is an array.
To fix this, I added the items property under the array within the object. So in the case of the example, the items
property should go under myProperty
like this:
openapi: '3.0.3'
info:
version: 1.0.0
title: Minimal Repro
paths:
/ping:
get:
responses:
'200':
description: OK
components:
schemas:
Config:
title: Config
type: object
properties:
myProperty:
type: array
default: [a, b, c]
items:
type: string
I also ran into this with v7.0.0.
Putting together what Xavientois quoted from the specs
items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. items MUST be present if the type is array.
and what fpinatares mentioned about his array missing items
, I believe that the actual bug is that the error points to the wrong object. It is the array that is missing items
, not the object.
It should probably read something like
attribute components.schemas.Config.myProperty.items is missing
instead of
attribute components.schemas.Config.items is missing
I've also run into this issue, and wondering if openapi-generator
supports adding this missing items on an array through the mappings feature?
(Or anything else to fix the issue without directly editing the spec?)
Bug Report Checklist
Description
I am trying to generate client code for a schema, but it gives me an error saying
This is confusing to me, as the 3.0.3 spec says:
openapi-generator version
OpenAPI declaration file content or url
Steps to reproduce