🇺🇸 English | 🇷🇺 Русский | 🇨🇳 中文
Removes the maxItems property from all schemas in the OpenAPI specification.
| Parameter | Description | Example | Type | Default |
|---|---|---|---|---|
showUnusedWarning |
[optional] Show a warning if no schemas with maxItems are found | true |
boolean |
false |
Configuration example:
module.exports = {
pipeline: [
// ... other rules
{
rule: "remove-max-items",
config: {} // remove maxItems property from all schemas, don't show warnings
}
// ... other rules
]
}Example of more detailed configuration:
module.exports = {
pipeline: [
// ... other rules
{
rule: "remove-max-items",
config: {
showUnusedWarning: true // show warning if no schemas with maxItems are found in the specification
}
}
// ... other rules
]
}If you need to modify multiple specifications, you can use this rule multiple times in the overall configuration pipeline.
In some cases, the maxItems constraint can interfere with code generation or create unnecessary checks. Removing this property makes the schema more flexible and universal.
Practical example:
In the openapi.yaml file, the schema looks like this:
components:
schemas:
Pet:
type: object
properties:
tags:
type: array
maxItems: 10
items:
type: stringIn the configuration file openapi-modifier-config.js, add the remove-max-items rule:
module.exports = {
pipeline: [
{
rule: "remove-max-items",
config: {
showUnusedWarning: true
},
}
]
}After applying the rule, the openapi.yaml file looks like this:
components:
schemas:
Pet:
type: object
properties:
tags:
type: array
items:
type: string- The rule does not affect schemas defined via references ($ref)
- If
showUnusedWarningis enabled, the rule will show a warning if no schemas withmaxItemsare found, to help keep the openapi-modifier configuration up to date