oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Strict server with additionalProperties

Open ShouheiNishi opened this issue 2 years ago • 4 comments

The strict server cannot return JSON object with additionalProperties. It seems that wrapper for strict server ignore custom MarshalJSON().

We do not create the minimal test code for this issue yet.

ShouheiNishi avatar Sep 11 '23 02:09 ShouheiNishi

Test code is https://github.com/ShouheiNishi/oapi-codegen/commit/19373ab96086a7d8c6cec20059c918fb2e42db54.

ShouheiNishi avatar Sep 11 '23 02:09 ShouheiNishi

We are also being bitten by this issue.

alehed avatar Mar 05 '24 09:03 alehed

I also experienced this issue. As a workaround I figured out that if you wrap the schema with the "additionalProerties" tag into a another schema like:

---
components:
  schemas:
    DataWrapper: # using this will marshal/unmarshal the additionalProperties
      type: object
      properties:
        data:
          $ref: "#/components/schemas/WithAdditionalProperies"
      example:
        data:
          fixedProperty: "Hello World"
          additionalPropertyFoo: "Bar"
          key: "value"
          unknown: "known"
    WithAdditionalProperies: # using this will NOT marshal/unmarshal the additionalProperties
      type: object
      properties:
        fixedProperty:
         type: string
      additionalProperty: true ## or {}
      example:
        fixedProperty: "Hello World"
        additionalPropertyFoo: "Bar"
        key: "value"
        unknown: "known"

it is working.

LucasMaciuga avatar Apr 25 '24 06:04 LucasMaciuga