# amnic — 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) # - servers-expected-domain: 1/1 servers on amnic.com # - schema-names-casing: pascal @ 100% (n=5) # - security: global (root) — NOT emitting operation-security-required # - error-schema-defined: ErrorResponse # - merge: kept 31 existing, added 3 measured, upgraded 0 # - added: servers-expected-domain, schema-names-casing, error-schema-defined extends: - spectral:oas rules: info-title-prefix: description: API title should start with "Amnic". severity: warn given: $.info.title then: function: pattern functionOptions: match: ^Amnic info-description-required: description: API info must have a description of at least 20 characters. severity: error given: $.info then: field: description function: truthy info-version-required: description: API info must define a version. severity: error given: $.info then: field: version function: truthy info-contact-required: description: API info should include contact information. severity: warn given: $.info then: field: contact function: truthy openapi-version-3: description: OpenAPI version must be 3.0.x. severity: error given: $.openapi then: function: pattern functionOptions: match: ^3\.0\. servers-defined: description: At least one server must be defined. severity: error given: $ then: field: servers function: truthy servers-https: description: Server URLs must use HTTPS. severity: error given: $.servers[*].url then: function: pattern functionOptions: match: ^https:// servers-description: description: Each server should have a description. severity: warn given: $.servers[*] then: field: description function: truthy paths-kebab-case: description: Path segments should use kebab-case (lowercase with hyphens). severity: warn given: $.paths[*]~ then: function: pattern functionOptions: match: ^(/[a-z0-9{}-]+)+$ paths-no-trailing-slash: description: Paths must not have trailing slashes. severity: error 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-summary-prefix: description: Operation summaries should start with "Amnic". severity: warn given: $.paths[*][get,post,put,patch,delete,head,options].summary then: function: pattern functionOptions: match: ^Amnic 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-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: operationId 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: error given: $.paths[*][get,post,put,patch,delete,head,options] then: field: tags function: truthy tags-global-defined: description: Global tags array should be defined. severity: warn given: $ then: field: tags function: truthy tags-description: description: Global tags should have descriptions. severity: warn given: $.tags[*] then: field: description function: truthy parameter-description-required: description: Every parameter must have a description. severity: error given: $.paths[*][*].parameters[*] then: field: description function: truthy parameter-snake-case: description: Query and path parameter names should use snake_case or kebab-case. severity: warn given: $.paths[*][*].parameters[?(@.in == 'query')].name then: function: pattern functionOptions: match: ^[a-z][a-z0-9_]*$ request-body-content-type: description: Request bodies should use application/json content type. severity: warn given: $.paths[*][post,put,patch].requestBody.content then: field: application/json 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-401-required: description: Operations with security should document a 401 response. severity: warn given: $.paths[*][get,post,put,patch,delete].responses then: field: '401' function: truthy response-description-required: description: Every response must have a description. severity: error given: $.paths[*][*].responses[*] then: field: description function: truthy schema-description-required: description: Top-level schemas should have a description. severity: warn given: $.components.schemas[*] then: field: description function: truthy schema-property-snake-case: description: Schema property names should use snake_case. severity: warn given: $.components.schemas[*].properties[*]~ then: function: pattern functionOptions: match: ^[a-z][a-z0-9_]*$ security-scheme-defined: description: Security schemes must be defined in components. severity: error given: $.components then: field: securitySchemes function: truthy security-global-defined: description: Global security should be defined. severity: warn given: $ then: field: security 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: error given: $..description then: function: pattern functionOptions: match: .+ examples-encouraged: description: Operations should include examples for better documentation. severity: info given: $.paths[*][*].responses[*].content[*] then: field: examples function: truthy servers-expected-domain: description: Server URLs should be on the amnic.com domain. severity: warn given: $.servers[*].url then: function: pattern functionOptions: match: amnic\.com 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 error-schema-defined: description: A shared error schema (ErrorResponse) should be defined for error payloads. severity: warn given: $.components.schemas then: field: ErrorResponse function: truthy