# backstage — Spectral ruleset (strengthened) # Plain Spectral. Existing hand-authored rules preserved; measured rules added # from this provider's own OpenAPI conventions by strengthen_ruleset.py, # then self-validated against the spec. # # Provenance: # - servers-https-only: 100% of servers already https (error) # - path-params-casing: snake @ 88% (n=41) # - query-params-casing: snake @ 79% (n=24) # - operationid-casing: camel @ 97% (n=38) # - schema-names-casing: pascal @ 100% (n=15) # - schema-properties-casing: snake @ 73% (n=60) # - operation-security-required: 35/38 ops declare per-op security # - pagination params observed: ['cursor', 'limit'] # - merge: kept 21 existing, added 6 measured, upgraded 0 # - added: servers-https-only, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, operation-security-required extends: - spectral:oas rules: info-title-required: description: Info must have a title severity: error given: $.info then: field: title function: truthy info-description-required: description: Info must have a description severity: warn given: $.info then: field: description function: truthy info-version-required: description: Info must have a version severity: error given: $.info then: field: version function: truthy openapi-version-3: description: Must use OpenAPI 3.0.x or 3.1.x severity: error given: $ then: field: openapi function: pattern functionOptions: match: ^3\. servers-defined: description: Servers must be defined severity: warn given: $ then: field: servers function: truthy paths-kebab-case: description: Path segments should use kebab-case severity: warn given: $.paths then: function: pattern functionOptions: match: ^(/[a-z0-9][a-z0-9-]*(/[a-z0-9][a-z0-9-]*|/\{[a-zA-Z0-9_]+\})*)*$ paths-no-trailing-slash: description: Paths must not have trailing slashes severity: warn given: $.paths then: function: pattern functionOptions: notMatch: /$ 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 must have a description severity: warn given: $.paths[*][get,post,put,patch,delete,head,options] then: field: description function: truthy operation-id-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-id-camel-case: description: OperationIds should 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: warn given: $.paths[*][get,post,put,patch,delete,head,options] then: field: tags function: truthy operation-summary-backstage-prefix: description: Operation summaries should start with "Backstage" severity: info given: $.paths[*][get,post,put,patch,delete,head,options].summary then: function: pattern functionOptions: match: ^Backstage parameter-description-required: description: All parameters must have descriptions severity: warn given: $.paths[*][get,post,put,patch,delete,head,options].parameters[*] then: field: description function: truthy response-success-required: description: Every operation must have at least one 2xx response severity: error given: $.paths[*][get,post,put,patch,delete] then: field: responses function: truthy response-description-required: description: Every response must have a description severity: error given: $.paths[*][get,post,put,patch,delete].responses[*] then: field: description function: truthy response-401-defined: description: Protected operations should define a 401 response severity: info given: $.paths[*][post,put,patch,delete] then: field: responses.401 function: truthy schema-type-defined: description: All schemas should have a type severity: warn given: $.components.schemas[*] then: field: type function: truthy security-schemes-defined: description: Security schemes must be defined if auth is used severity: info given: $.components then: field: securitySchemes function: truthy get-no-request-body: description: GET operations must not have a request body severity: error given: $.paths[*].get then: field: requestBody function: falsy no-empty-descriptions: description: Descriptions must not be empty strings severity: warn given: $..description then: function: truthy servers-https-only: description: Server URLs must use HTTPS. severity: error given: $.servers[*].url then: function: pattern functionOptions: match: ^https:// path-params-casing: description: Path parameters should be snake_case (the dominant convention in this API). severity: warn given: $.paths[*].parameters[?(@.in=='path')].name then: function: casing functionOptions: type: snake query-params-casing: description: Query parameters should be snake_case (the dominant convention in this API). severity: warn given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')] then: field: name function: casing functionOptions: type: snake schema-names-casing: description: Component schema names should be PascalCase (the dominant convention in this API). severity: warn given: $.components.schemas then: field: '@key' function: casing functionOptions: type: pascal schema-properties-casing: description: Schema properties should be snake_case (the dominant convention in this API). severity: info given: $.components.schemas[*].properties then: field: '@key' function: casing functionOptions: type: snake operation-security-required: description: Every operation should declare its security requirements. severity: warn given: $.paths[*][get,post,put,patch,delete] then: field: security function: truthy