{
    "extends": [
        "spectral:oas"
    ],
    "rules": {
        "ispbills-info-description": {
            "description": "Describe the implemented API and its limitations.",
            "severity": "error",
            "given": "$.info",
            "then": {
                "field": "description",
                "function": "truthy"
            }
        },
        "ispbills-https-servers": {
            "description": "Published API servers use HTTPS.",
            "severity": "error",
            "given": "$.servers[*].url",
            "then": {
                "function": "pattern",
                "functionOptions": {
                    "match": "^https://"
                }
            }
        },
        "ispbills-operation-summary": {
            "description": "Every operation has a human-readable summary.",
            "severity": "error",
            "given": "$.paths[*][get,put,post,delete,patch,options,head,trace]",
            "then": {
                "field": "summary",
                "function": "truthy"
            }
        },
        "ispbills-operation-description": {
            "description": "Every operation describes its behavior and access requirements.",
            "severity": "error",
            "given": "$.paths[*][get,put,post,delete,patch,options,head,trace]",
            "then": {
                "field": "description",
                "function": "truthy"
            }
        },
        "ispbills-operation-id": {
            "description": "Preserve stable route-derived identifiers, including dotted and hyphenated names.",
            "severity": "warn",
            "given": "$.paths[*][get,put,post,delete,patch,options,head,trace].operationId",
            "then": {
                "function": "pattern",
                "functionOptions": {
                    "match": "^[a-z][a-zA-Z0-9]*([.-][a-z][a-zA-Z0-9]*)*$"
                }
            }
        },
        "ispbills-client-error-response": {
            "description": "Every operation documents at least one HTTP 4xx response.",
            "severity": "error",
            "given": "$.paths[*][get,put,post,delete,patch,options,head,trace].responses",
            "then": {
                "function": "schema",
                "functionOptions": {
                    "schema": {
                        "type": "object",
                        "not": {
                            "propertyNames": {
                                "not": {
                                    "pattern": "^4[0-9]{2}$"
                                }
                            }
                        }
                    }
                }
            }
        },
        "ispbills-rate-limit-response": {
            "description": "All v2 operations are throttled and document HTTP 429.",
            "severity": "error",
            "given": "$.paths[*][get,put,post,delete,patch,options,head,trace].responses",
            "then": {
                "field": "429",
                "function": "truthy"
            }
        },
        "ispbills-read-no-body": {
            "description": "Read operations use parameters, not request bodies.",
            "severity": "error",
            "given": "$.paths[*][get,head]",
            "then": {
                "field": "requestBody",
                "function": "undefined"
            }
        },
        "ispbills-request-body-required": {
            "description": "Explicitly distinguish required payloads from optional payloads.",
            "severity": "warn",
            "given": "$.paths[*][post,put,patch,delete].requestBody",
            "then": {
                "field": "required",
                "function": "defined"
            }
        },
        "ispbills-integration-guide": {
            "description": "Link the integration guide for authentication, retry safety and limitations.",
            "severity": "info",
            "given": "$",
            "then": {
                "field": "externalDocs.url",
                "function": "truthy"
            }
        }
    }
}