-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: no-required-schema-properties-undefined markdown docs (#1417)
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
slug: /docs/cli/rules/no-required-schema-properties-undefined | ||
--- | ||
|
||
# no-required-schema-properties-undefined | ||
|
||
Ensures there are no required schema properties that are undefined. | ||
|
||
| OAS | Compatibility | | ||
| --- | ------------- | | ||
| 2.0 | ✅ | | ||
| 3.0 | ✅ | | ||
| 3.1 | ✅ | | ||
|
||
```mermaid | ||
flowchart TD | ||
Root ==> Components ==> Schemas | ||
style Schemas fill:#codaf9,stroke:#0044d4,stroke-width:5px | ||
``` | ||
|
||
## API design principles | ||
|
||
If a required schema property is declared but not defined, this rule informs you which of the required schema properties are missing. | ||
|
||
## Configuration | ||
|
||
| Option | Type | Description | | ||
| -------- | ------ | ---------------------------------------------------------------------------------------- | | ||
| severity | string | Possible values: `off`, `warn`, `error`. Default `off` (in `recommended` configuration). | | ||
|
||
An example configuration: | ||
|
||
```yaml | ||
rules: | ||
no-required-schema-properties-undefined: error | ||
``` | ||
## Examples | ||
Given this configuration: | ||
```yaml | ||
rules: | ||
no-required-schema-properties-undefined: error | ||
``` | ||
Example of **incorrect** schema properties: | ||
```yaml | ||
schemas: | ||
Pet: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
``` | ||
Expected error message when linting incorrect schema example: | ||
```bash | ||
Required property 'name' is undefined. | ||
``` | ||
|
||
Example of **correct** schema properties: | ||
|
||
```yaml | ||
schemas: | ||
Pet: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
example: doggie | ||
``` | ||
## Related rules | ||
- [no-invalid-schema-examples](./no-invalid-schema-examples.md) | ||
## Resources | ||
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/common/no-required-schema-properties-undefined.ts) | ||
- [Schema docs](https://redocly.com/docs/openapi-visual-reference/schemas/) |
1f1ec5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report
Test suite run success
710 tests passing in 101 suites.
Report generated by 🧪jest coverage report action from 1f1ec5c