ogen icon indicating copy to clipboard operation
ogen copied to clipboard

Incorrect generation of free-form objects

Open mxk opened this issue 1 year ago • 0 comments

OpenAPI Guide states that additionalProperties: true is the default when a schema consists of just type: object, but the generated code ends up with a struct{} type unless additionalProperties: true is specified.

What version of ogen are you using?

v1.0.1-0.20240411144324-e1628ac9f35f

Can this issue be reproduced with the latest version?

Yes

What did you do?

Changed schema from:

"schema": {
  "type": "object"
}

to:

"schema": {
  "type": "object"
  "additionalProperties": true
}

What did you expect to see?

Generated code should be the same.

What did you see instead?

Without additionalProperties:

type MyApiReq struct{}

With additionalProperties:

type MyApiReq map[string]jx.Raw

mxk avatar Apr 11 '24 19:04 mxk