rules: # INFO / METADATA info-title-required: description: Info title must be present and follow "1Factory ..." pattern. severity: error given: $.info then: field: title function: truthy info-description-required: description: Info description must be present and at least 50 characters. severity: warn given: $.info then: field: description function: minLength functionOptions: value: 50 info-version-required: description: API version must be defined. severity: error given: $.info then: field: version function: truthy info-contact-required: description: Contact information must be provided. severity: warn given: $.info then: field: contact function: truthy info-terms-of-service: description: Terms of service URL should be provided. severity: info given: $.info then: field: termsOfService function: truthy # OPENAPI VERSION openapi-version-3: description: Must use OpenAPI 3.0.x. severity: error given: $ then: field: openapi function: pattern functionOptions: match: "^3\\.0\\." # SERVERS servers-must-be-defined: description: Servers array must be defined and non-empty. severity: error given: $ then: field: servers function: truthy servers-https-required: description: Production server URLs must use HTTPS. severity: error given: $.servers[*] then: field: url function: pattern functionOptions: match: "^https://" servers-description-required: description: Each server must have a description. severity: warn given: $.servers[*] then: field: description function: truthy # PATHS — NAMING CONVENTIONS paths-no-trailing-slash: description: Paths must not end with a trailing slash. severity: warn given: $.paths then: function: pattern functionOptions: notMatch: "/$" paths-no-query-string: description: Paths must not contain query strings. severity: error given: $.paths then: function: pattern functionOptions: notMatch: "\\?" # OPERATIONS operation-summary-required: description: Every operation must have a summary. severity: error given: $.paths[*][get,post,put,patch,delete,options,head] then: field: summary function: truthy operation-description-required: description: Every operation should have a description. severity: warn given: $.paths[*][get,post,put,patch,delete,options,head] then: field: description function: truthy operation-summary-prefix: description: Every operation summary should start with "1Factory". severity: warn given: $.paths[*][get,post,put,patch,delete,options,head].summary then: function: pattern functionOptions: match: "^1Factory " operation-tags-required: description: Every operation must have at least one tag. severity: error given: $.paths[*][get,post,put,patch,delete,options,head] then: field: tags function: truthy # TAGS tag-descriptions-required: description: Global tags must have descriptions. severity: warn given: $.tags[*] then: field: description function: truthy # PARAMETERS parameter-description-required: description: Every parameter must have a description. severity: warn given: $.paths[*][get,post,put,patch,delete,options,head].parameters[*] then: field: description function: truthy parameter-schema-required: description: Every parameter must have a schema. severity: error given: $.paths[*][get,post,put,patch,delete,options,head].parameters[*] then: field: schema function: truthy # REQUEST BODIES request-body-description: description: Request bodies should have a description. severity: info given: $.paths[*][post,put,patch].requestBody then: field: description function: truthy request-body-json-content: description: Request bodies should use application/json content type. severity: warn given: $.paths[*][post,put,patch].requestBody.content then: function: schema functionOptions: schema: type: object required: - application/json # RESPONSES response-success-required: description: Every operation must define at least one 2xx response. severity: error given: $.paths[*][get,post,put,patch,delete,options,head].responses then: function: schema functionOptions: schema: type: object minProperties: 1 response-description-required: description: Every response must have a description. severity: error given: $.paths[*][get,post,put,patch,delete,options,head].responses[*] then: field: description function: truthy response-401-required: description: APIs using API key auth should define a 401 response. severity: warn given: $.paths[*][get,post,put,patch,delete].responses then: function: schema functionOptions: schema: type: object properties: '401': type: object response-429-rate-limit: description: Rate-limited APIs should define a 429 response. severity: info given: $.paths[*][get,post,put,patch,delete].responses then: function: schema functionOptions: schema: type: object properties: '429': type: object # SCHEMAS — PROPERTY NAMING schema-description-required: description: Top-level component schemas should have descriptions. severity: warn given: $.components.schemas[*] then: field: description function: truthy schema-type-required: description: Schemas should define a type. severity: warn given: $.components.schemas[*] then: field: type function: truthy # SECURITY security-schemes-defined: description: Security schemes must be defined in components. severity: error given: $.components then: field: securitySchemes function: truthy security-api-key-in-header: description: API keys should be passed in headers, not query parameters. severity: warn given: $.components.securitySchemes[*][?(@.type == 'apiKey')] then: field: in function: enumeration functionOptions: values: - header # 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 # GENERAL QUALITY no-empty-descriptions: description: Descriptions should not be empty strings. severity: warn given: $..description then: function: truthy examples-encouraged: description: Schema properties should include example values. severity: info given: $.components.schemas[*].properties[*] then: field: example function: truthy