rules: # INFO / METADATA info-title-required: description: Info object must have a title severity: error given: "$.info" then: field: title function: truthy info-description-required: description: Info object must have a description of at least 20 characters severity: warn given: "$.info" then: field: description function: minLength functionOptions: value: 20 info-version-required: description: Info object must have a version severity: error given: "$.info" then: field: version function: truthy # OPENAPI VERSION openapi-version-3: description: Specs must use OpenAPI 3.x severity: warn given: "$" then: field: openapi function: pattern functionOptions: match: "^3\\." # SERVERS servers-defined: description: Servers array must be defined and non-empty severity: error given: "$" then: field: servers function: truthy servers-https: description: Server URLs must use HTTPS severity: warn given: "$.servers[*].url" then: function: pattern functionOptions: match: "^https://" # PATHS - NAMING CONVENTIONS paths-kebab-case: description: Path segments must use kebab-case severity: warn given: "$.paths[*]~" then: function: pattern functionOptions: match: "^(/[a-z0-9{][a-z0-9-{}]*)*$" paths-no-trailing-slash: description: Paths must not end with a trailing slash severity: warn given: "$.paths[*]~" then: function: pattern functionOptions: notMatch: "/$" paths-versioned: description: Paths should include a version prefix severity: info given: "$.paths[*]~" then: function: pattern functionOptions: match: "^/v[0-9]" # OPERATIONS operation-summary-required: description: Every operation must have a summary severity: error given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: summary function: truthy operation-description-required: description: Every operation should have a description severity: warn given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: description function: truthy operation-operationid-required: description: Every operation must have an operationId severity: error given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: operationId function: truthy operation-operationid-camel-case: description: OperationId must use camelCase severity: warn given: "$.paths[*][get,post,put,patch,delete,head,options].operationId" then: function: pattern functionOptions: match: "^[a-z][a-zA-Z0-9]*$" operation-tags-required: description: Every operation must have at least one tag severity: error given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: tags function: truthy operation-summary-tm-forum-prefix: description: Operation summaries should start with 'TM Forum' severity: info given: "$.paths[*][get,post,put,patch,delete,head,options].summary" then: function: pattern functionOptions: match: "^TM Forum" # TAGS tag-name-title-case: description: Tag names in the global tags array should use Title Case severity: info given: "$.tags[*].name" then: function: pattern functionOptions: match: "^[A-Z]" tag-description-required: description: All global tags should have a description severity: info given: "$.tags[*]" then: field: description function: truthy # PARAMETERS parameter-description-required: description: All parameters must have a description severity: warn given: "$.paths[*][get,post,put,patch,delete][parameters][*]" then: field: description function: truthy parameter-name-snake-case: description: Parameter names should use snake_case or camelCase severity: info given: "$.paths[*][get,post,put,patch,delete][parameters][*].name" then: function: pattern functionOptions: match: "^[a-z][a-zA-Z0-9_.]*$" # REQUEST BODIES request-body-content-type-json: description: Request bodies should support application/json severity: warn given: "$.paths[*][post,put,patch].requestBody.content" then: function: schema functionOptions: schema: type: object required: ["application/json"] # RESPONSES response-success-required: description: Operations must define at least one 2xx success response severity: error given: "$.paths[*][get,post,put,patch,delete].responses" then: function: schema functionOptions: schema: type: object minProperties: 1 response-description-required: description: All response objects must have a description severity: error given: "$.paths[*][get,post,put,patch,delete].responses[*]" then: field: description function: truthy response-400-defined: description: Operations should define a 400 Bad Request response severity: info given: "$.paths[*][post,put,patch].responses" then: function: schema functionOptions: schema: type: object required: ["400"] response-401-defined: description: Operations should define a 401 Unauthorized response severity: info given: "$.paths[*][get,post,put,patch,delete].responses" then: function: schema functionOptions: schema: type: object required: ["401"] # SCHEMAS - PROPERTY NAMING schema-property-camel-case: description: Schema property names should use camelCase severity: info given: "$.components.schemas[*].properties[*]~" then: function: pattern functionOptions: match: "^[a-z][a-zA-Z0-9@.]*$" schema-type-defined: description: Schema properties should have a type defined severity: warn given: "$.components.schemas[*].properties[*]" then: function: schema functionOptions: schema: type: object anyOf: - required: ["type"] - required: ["$ref"] - required: ["allOf"] schema-description-required: description: Top-level schemas should have a description severity: info given: "$.components.schemas[*]" then: field: description function: truthy # SECURITY security-schemes-defined: description: Security schemes must be defined in components severity: warn given: "$.components" then: field: securitySchemes function: truthy # HTTP METHOD CONVENTIONS get-no-request-body: description: GET operations must not have a request body severity: error given: "$.paths[*].get" then: field: requestBody function: falsy delete-no-request-body: description: DELETE operations should not have a request body severity: warn given: "$.paths[*].delete" then: field: requestBody function: falsy post-has-request-body: description: POST operations creating resources should have a request body severity: info given: "$.paths[*].post" then: field: requestBody function: truthy # GENERAL QUALITY no-empty-descriptions: description: Description fields must not be empty strings severity: error given: - "$.info.description" - "$.paths[*][get,post,put,patch,delete].description" - "$.components.schemas[*].description" then: function: pattern functionOptions: match: "\\S" deprecation-documented: description: Deprecated operations should have a description explaining the deprecation severity: warn given: "$.paths[*][get,post,put,patch,delete][?(@.deprecated==true)]" then: field: description function: truthy examples-encouraged: description: Schema properties are encouraged to have example values severity: info given: "$.components.schemas[*].properties[*]" then: field: example function: truthy