United States Coast Guard · API Governance Rules

United States Coast Guard API Rules

Spectral linting rules defining API design standards and conventions for United States Coast Guard.

7 Rules error 3 warn 4
View Rules File View on GitHub

Rule Categories

cgmix

Rules

error
cgmix-operation-ids-required
All operations must have operationIds for client generation.
$.paths[*][get,post,put,delete,patch]
error
cgmix-vessel-id-required
PSIX endpoints require VesselID parameter.
$.paths[?(@property =~ /PSIXData/)][*].parameters[?(@.name == 'VesselID')]
warn
cgmix-xml-response-type
CGMIX APIs return XML responses.
$.paths[*][get,post].responses[*].content
warn
cgmix-operations-have-tags
All operations should have tags for grouping.
$.paths[*][get,post,put,delete,patch]
warn
cgmix-parameters-have-descriptions
All parameters should include descriptions.
$.paths[*][*].parameters[*]
warn
cgmix-info-contact
API info should include contact details.
$.info
error
cgmix-responses-documented
All operations should document at least a 200 response.
$.paths[*][get,post,put,delete,patch].responses

Spectral Ruleset

Raw ↑
rules:
  cgmix-operation-ids-required:
    description: All operations must have operationIds for client generation.
    message: Operation must have an operationId.
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: operationId
      function: truthy
    severity: error

  cgmix-vessel-id-required:
    description: PSIX endpoints require VesselID parameter.
    message: >-
      PSIX vessel operations must include VesselID as a required query
      parameter.
    given: "$.paths[?(@property =~ /PSIXData/)][*].parameters[?(@.name == 'VesselID')]"
    then:
      field: required
      function: truthy
    severity: error

  cgmix-xml-response-type:
    description: CGMIX APIs return XML responses.
    message: CGMIX operations should document text/xml response content type.
    given: "$.paths[*][get,post].responses[*].content"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            text/xml:
              type: object
    severity: warn

  cgmix-operations-have-tags:
    description: All operations should have tags for grouping.
    message: Operation must include at least one tag.
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: tags
      function: truthy
    severity: warn

  cgmix-parameters-have-descriptions:
    description: All parameters should include descriptions.
    message: Parameter must have a description.
    given: "$.paths[*][*].parameters[*]"
    then:
      field: description
      function: truthy
    severity: warn

  cgmix-info-contact:
    description: API info should include contact details.
    message: API info block must contain a contact object.
    given: "$.info"
    then:
      field: contact
      function: truthy
    severity: warn

  cgmix-responses-documented:
    description: All operations should document at least a 200 response.
    message: Operation must document a 200 success response.
    given: "$.paths[*][get,post,put,delete,patch].responses"
    then:
      field: "200"
      function: truthy
    severity: error