-
-
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
[BUG] ModelUtils.getAdditionalProperties returns ObjectSchema for "true" #9282
Comments
{} is an Object with no properties. Implying to me that the additonalProperties is best considered a separate object whose properties should be considered as part of the schema. The additional properties need to be a mapping of string property names to objects as constrained by the additionalProperties type so wouldn't they be stored in an object schema? If this works functionally I don't see why the implementation methodology is a bug. (But I'm new to this so be kind!) |
The value of a schema's Technically from a JSON schema validation standpoint, the schema So, if we interpret
that would imply that arbitrary properties must be an "object" of some sort (e.g.
would allow arbitrary properties of any type |
Well I think we are agreeing that ,
and JSON |
Figured out where I went sideways. :) My head was in instances not models. Where you say
|
My interpretation of the OpenAPI spec is that the
Example JSON instances for each of these schemas might look like this: S1: S2: S3: My main point here is that the schema specified as the value of the Following this line of thinking, |
👍 |
Bug Report Checklist
Description
If a schema contains
additionalProperties: true
, that is supposed to be equivalent toadditionalProperties: {}
, which implies that arbitrary properties of ANY type (string, integer, object, etc.) may be added to the object/class/struct that is generated for that schema.However,
ModelUtils.getAdditionalProperties()
will return an instance of ObjectSchema in this case rather than an instance of Schema. This would be equivalent to a schema with this value for the additionalProperties field:This would imply that arbitrary properties added to the object/class/struct for that schema should be an "object" (i.e. Map<String,Object> in Java, map[string]interface{} in Go, etc.).
openapi-generator version
This was observed in an old version of the project (3.3.3) and is still present in the latest from the master branch.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Modify ModelUtils.getAdditionalProperties() so that it returns an instance of Schema instead of ObjectSchema in the scenario where
additionalProperties: true
is detected.The text was updated successfully, but these errors were encountered: