Skip to content

v2 - Allow setting Extensions with JsonNode values #2151

Closed
@mikekistler

Description

@mikekistler

Is your feature request related to a problem? Please describe.

OpenApi.Net v2 allows example properties to be set with a JsonNode value. This is a very welcome improvement as the 1.6 release required examples to be set using types from the OpenApi.Any package.

Unfortunately, it appears that spec extensions require values that are IOpenApiExtensions, which means that they cannot have values that are JsonNodes but must be wrapped in an OpenApiAny object, like this:

            schema.Extensions["x-dictionaryKey"] = // an object with $ref to the key schema
                 new OpenApiAny( new JsonObject() {["$ref"] = $"#/components/schemas/{keyType.Name}" });

Describe the solution you'd like

Like examples, I'd like to be able to use simple JsonNode values as the value of an Extension setting, like this:

            schema.Extensions["x-dictionaryKey"] = // an object with $ref to the key schema
                 new JsonObject() {["$ref"] = $"#/components/schemas/{keyType.Name}" };

Describe alternatives you've considered

I can use OpenApiAny -- it's just cumbersome and difficult to discover and inconsistent with the way examples can be defined.

Metadata

Metadata

Assignees

Labels

priority:p2Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions