-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial CAMARA OAS linting ruleset #74
Conversation
Problem with operation-operationId
### Rule severity | ||
|
||
The `severity` keyword is optional in rule definition and can be `error`, `warn`, `info`, `hint`, or `off`. | ||
The default value is `warn`. |
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.
We should discuss what is the expected outcome for each severity. For example should warn
result in a change and re-lint, or can it be ignored?
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.
Good point. Maybe we can differentiate along the following lines:
- warnings can be ignored when introducing linting first time
- OR (alternative) warnings can be ignored if correcting them would introduce a breaking change
- warnings shall not be introduced with a change (e.g. within a merge, that's the point where linting is done)
But that's to clarify in a next version. Will you open an issue for that @Kevsy ?
Excellent start @rartych - I 've submitted an Approval, and have made one question in the review about the expected outcome for each severity, which we can include n the next version. |
|
||
*Severity*: `hint` | ||
|
||
## 3. API Definition |
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.
Here are a few valid scenarios that we can consider for API validation.
Topic | Description |
---|---|
Openapi version | Camara APIs MUST be based on OpenAPI specification with minimum Version 3.0.0. |
Request body structure on PUT, POST, PATCH | POST / PUT / PATCH methods must have a requestBody. The requestBody content must be "application/json" or "application/xml". |
Info object: title, version, description | "Info" section is mandatory. Title, Description and Version must be documented.Note: It is provided by Spectral. |
Info object: API version format | API version within the Info section must follow the format: X.Y.Z |
Valid basepath validation | API must have valid basepath |
Camel case / lower case /Snake_Case | Paths URI (tasks, individual resources, etc.) MUST be lower case and hyphens. OperationIds must be defined in lowerCamelCase. Objects must be defined in CamelCase inside properties field. The event type must be written in UPPER_SNAKE_CASE |
Path URI | URIs must contain the "major version" of the API. |
Resource path must not contain the base URL | Path must not contain the base path. |
Sensitive data (msisdn/imsi) cannot be a path or query parameter | Sensitive data (msisdn/imsi) cannot be a path or query parameter.Note: Needs to list down if we have other sensitive parameters other than MSISDN/IMSI |
Valid methods | Valid methods method are: GET, PUT, POST, DELETE, PATCH, OPTIONS, HEAD |
GET/DELETE methods must not accept a "body" | 'GET' and 'DELETE' http methods MUST NOT accept a 'requestBody' attribute |
Define common error response pattern | Following error responses must be define: 400, 401, 403, 404, 405, 406, 429, 500, 501, 502, 503, 504.Note: List needs to be validated as per Camara API documentation |
Verb methods cannot be in the Path | Resources must not contain the method name get, put, post, delete, patch. |
Parameters must have a description | All parameters must have a description. |
Path version must be major versions only | Path must contain the major API version with format /vX.Example: paths: "/device-status/v0/roaming" |
GET/DELETE methods must not accept a "body" | 'GET' and 'DELETE' http methods MUST NOT accept a 'requestBody' attribute |
Mandatory request body with POST, PATCH and PUT methods | The requestBody object MAY be present when the operation is used with one of PUT, POST, PATCH HTTP Verbs. |
Summary associated with each operation | Summary must be defined on each operation, describing with a short summary what the operation does. |
Include valid response examples | For each response code, we must define response payload examples |
Thank you @sachinvodafone for your input. I have added comments inline: Some topics have to wait for clarification and update of Design Guidelines.
|
Hi @rartych , we can ignore duplicate items (16 & 17) that you have highlighted . It seems , some issue in copy/paste . Also I am aligned with point 6 (Event Type) and 10 (HEAD) comments. Apart from this , few others validation can be considered:
Example of 20 & 21 is
|
New rules for topics: 1, 2, 3, 4, 9, 10, 11, 13, 14, 18 added
Update Linting-rules.md
OperationId casing clarified - no contradiction with Spectral core rules
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.
Very good starting point. Just some minor comments. the camara-* spectral rules are yet to be developed in a later iteration, right?
documentation/Linting-rules.md
Outdated
|Name| Desc| Recom mended|CAMARA use|Spectral severity | CAMARA severity | ||
|---|---|---|--|---|--| | ||
|contact-properties| contact object is full of the most useful properties: `name`, `url`, `and email`|No|No | Warning | | | ||
|duplicated-entry-in-enum| Each value of an `enum` must be different from one another |Yes | Yes | Warning | | |
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.
This should be an error
Co-authored-by: Jose Luis Urien <[email protected]>
@jlurien Thank you for your comments.
We (within DT) are developing these additional rules (camara-*) and intend to extend this PR with the code. Another question is testing the ruleset against current API specification in subprojects to minimize false positives. |
My feeling is that this task is too big to keep all work in one PR, so we may iterate, but I let you decide what to include here. I can help testing with Device Location APIs |
Clarifications on Spectral core ruleset
Table summarizing camara- linting rules
camara-oas-version severity
More granular rules for objects descriptions
Artifacts are proposed in the other PR
What type of PR is this?
Add one of the following kinds:
What this PR does / why we need it:
The list of core Spectral OAS rules and proposed additional rules to be used for linting OAS files within subprojects
Which issue(s) this PR fixes:
Fixes #15
Special notes for reviewers:
Draft version for discussion, evolution and implementation details expected in the next round
Changelog input
Additional documentation
Spectral docs