extends: spectral:oas rules: # Service Fabric API uses PascalCase for operationIds service-fabric-operation-id-pascal-case: description: Service Fabric operationIds should use camelCase matching the REST style message: "operationId '{{value}}' must use camelCase" severity: warn given: "$.paths[*][get,post,put,patch,delete].operationId" then: function: pattern functionOptions: match: "^[a-z][a-zA-Z0-9]+$" # All operations must have operationId service-fabric-operation-id-required: description: All operations must have an operationId message: "Operation must have an operationId" severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: operationId function: defined # All operations must have a summary service-fabric-operation-summary-required: description: All operations must have a summary message: "Operation must have a summary" severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: summary function: defined # Service Fabric always requires api-version parameter service-fabric-api-version-required: description: Service Fabric API requires an api-version query parameter on all operations message: "Operation should include the api-version query parameter" severity: warn given: "$.paths[*][get,post,put,patch,delete]" then: field: parameters function: defined # Tags must be from allowed list service-fabric-valid-tags: description: Operations must use tags from the defined Service Fabric tag list message: "Tag '{{value}}' is not in the Service Fabric tag list" severity: warn given: "$.paths[*][get,post,put,patch,delete].tags[*]" then: function: enumeration functionOptions: values: - Cluster - Nodes - Applications - Services - Partitions - Health # All operations must have tags service-fabric-tags-required: description: All operations must have at least one tag message: "Operation must have at least one tag" severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: tags function: length functionOptions: min: 1 # Health state enum values should be consistent service-fabric-health-state-enum: description: Health state properties must use standard Service Fabric enum values message: "HealthState enum should include Invalid, Ok, Warning, Error, Unknown" severity: info given: "$.components.schemas[*].properties[?(@property === 'HealthState' || @property === 'AggregatedHealthState')]" then: function: defined # Responses should define success codes service-fabric-success-response: description: Operations must define a success response message: "Operation must have a 200 or 201 response defined" severity: error given: "$.paths[*][get,post,put,patch,delete].responses" then: function: schema functionOptions: schema: oneOf: - required: ["200"] - required: ["201"]