Service Fabric · API Governance Rules

Service Fabric API Rules

Spectral linting rules defining API design standards and conventions for Service Fabric.

8 Rules error 4 warn 3 info 1
View Rules File View on GitHub

Rule Categories

service

Rules

warn
service-fabric-operation-id-pascal-case
Service Fabric operationIds should use camelCase matching the REST style
$.paths[*][get,post,put,patch,delete].operationId
error
service-fabric-operation-id-required
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
error
service-fabric-operation-summary-required
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
service-fabric-api-version-required
Service Fabric API requires an api-version query parameter on all operations
$.paths[*][get,post,put,patch,delete]
warn
service-fabric-valid-tags
Operations must use tags from the defined Service Fabric tag list
$.paths[*][get,post,put,patch,delete].tags[*]
error
service-fabric-tags-required
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
info
service-fabric-health-state-enum
Health state properties must use standard Service Fabric enum values
$.components.schemas[*].properties[?(@property === 'HealthState' || @property === 'AggregatedHealthState')]
error
service-fabric-success-response
Operations must define a success response
$.paths[*][get,post,put,patch,delete].responses

Spectral Ruleset

Raw ↑
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"]