swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

OpenApiMixin extensions should include Null values

Open loomisdf opened this issue 3 years ago • 1 comments

Summary

Ran into this issue while working with springdocs-openapi https://github.com/springdoc/springdoc-openapi/issues/1525 Null vendor exensions are allowed via the OpenAPI spec detailed here

The extension value can be a primitive, an array, an object or null

However, they are not being rendered because the OpenApiMixins class is not setup to do so.

Expected Output

"x-my-vendor-extensions": {
	"property1": "value1",
        "property2": null
}

Actual Output

"x-my-vendor-extensions": {
	"property1": "value1"
}

Solution

I believe the @JsonInclude(value = Include.ALWAYS) annotation should be added here.

@JsonAnyGetter
@JsonInclude(value = Include.ALWAYS)
public abstract Map<String, Object> getExtensions();

A similar workaround has been added to the springdocs-openapi project.

loomisdf avatar Feb 28 '22 20:02 loomisdf

@HugoMario could you take a look into fixing this, if it's still an issue. Thanks!

ponelat avatar Jun 02 '22 15:06 ponelat

fixed by #4468

HugoMario avatar Aug 26 '23 06:08 HugoMario