Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions registries/_extension/x-jsonschema-maxContains.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
owner: baywet
issue:
description: The maximum number of array elements that may match contains, used when targeting OpenAPI versions that do not directly support maxContains.
schema:
type: integer
minimum: 0
objects: [ "Schema Object" ]
layout: default
---

{% capture summary %}
JSON Schema defines the `maxContains` keyword to set the maximum number of array elements that may match `contains`.

The `x-jsonschema-maxContains` extension mirrors this JSON Schema keyword when targeting OpenAPI versions where the keyword is not directly available, serializing it as `x-jsonschema-maxContains`.

It can appear as a property in the following objects: `{{page.objects|jsonify}}`.

Used by: (informational)

* [Microsoft.OpenApi](https://github.com/microsoft/OpenAPI.NET) (.NET OpenAPI library)
{% endcapture %}

{% capture example %}
```yaml
openapi: 3.0.4
info:
title: My API
version: 1.0.0
paths: {}
components:
schemas:
Roles:
type: array
items:
type: string
x-jsonschema-contains:
const: admin
x-jsonschema-maxContains: 1
```
{% endcapture %}

{% include extension-entry.md summary=summary example=example %}