Vforquest
Vforquest

Reputation: 181

Is there a maxLength or an alternative keyword in OpenAPI 3

In openapis.org OpenAPI 3.0(https://spec.openapis.org/oas/v3.1.0), I am unable to find maxLength keyword to denote the max length allowed for a datatype nor an alternate. Can anyone help, do I need to do it with x-?

Upvotes: 17

Views: 22319

Answers (1)

Markus Meyer
Markus Meyer

Reputation: 3967

It's tricky to find it:

4.4 Data Types :

As defined by the JSON Schema Validation vocabulary, data types can have an optional modifier property: format. OAS defines additional formats to provide fine detail for primitive data types.

JSON Schema Validation:
This document contains the description for maxLength

6.3.1. maxLength The value of this keyword MUST be a non-negative integer. A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 8259 [RFC8259].

It's easier to find the documentation in OpenAPI Version 3.0.3

Upvotes: 7

Related Questions