US Citizenship and Immigration Services · API Governance Rules

US Citizenship and Immigration Services API Rules

Spectral linting rules defining API design standards and conventions for US Citizenship and Immigration Services.

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

Rule Categories

uscis

Rules

warn
uscis-info-contact
USCIS API specs must include contact information
$.info
warn
uscis-operation-tags
All operations must be tagged
$.paths[*][get,post,put,patch,delete]
error
uscis-operation-summary
All operations must have a summary in Title Case
$.paths[*][get,post,put,patch,delete]
error
uscis-operation-id
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
uscis-operation-description
All operations must have a description
$.paths[*][get,post,put,patch,delete]
warn
uscis-parameter-description
All parameters must have a description
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
uscis-oauth2-security
USCIS APIs should use OAuth 2.0 security
$.components.securitySchemes
warn
uscis-response-schema
All 200/201 responses must have a schema
$.paths[*][get,post,put,patch,delete].responses[200,201]
info
uscis-receipt-number-pattern
Receipt number path parameters should have a pattern
$.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'receiptNumber')]
warn
uscis-error-responses
Operations should document 401 and 429 error responses
$.paths[*][get,post,put,patch,delete].responses
warn
uscis-json-content-type
USCIS API should use JSON content types
$.paths[*][post,put,patch].requestBody.content
error
uscis-version-in-info
API must specify version
$.info

Spectral Ruleset

Raw ↑
rules:
  uscis-info-contact:
    description: USCIS API specs must include contact information
    message: "Contact information is required in info object"
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  uscis-operation-tags:
    description: All operations must be tagged
    message: "Operation must have at least one tag"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  uscis-operation-summary:
    description: All operations must have a summary in Title Case
    message: "Operation '{{property}}' must have a summary"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  uscis-operation-id:
    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: truthy

  uscis-operation-description:
    description: All operations must have a description
    message: "Operation must have a description"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  uscis-parameter-description:
    description: All parameters must have a description
    message: "Parameter must have a description"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].parameters[*]"
    then:
      field: description
      function: truthy

  uscis-oauth2-security:
    description: USCIS APIs should use OAuth 2.0 security
    message: "Security schemes should include OAuth2"
    severity: warn
    given: "$.components.securitySchemes"
    then:
      function: truthy

  uscis-response-schema:
    description: All 200/201 responses must have a schema
    message: "Successful responses must have content with schema"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses[200,201]"
    then:
      field: content
      function: truthy

  uscis-receipt-number-pattern:
    description: Receipt number path parameters should have a pattern
    message: "Receipt number parameter should have pattern validation"
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'receiptNumber')]"
    then:
      field: schema.pattern
      function: truthy

  uscis-error-responses:
    description: Operations should document 401 and 429 error responses
    message: "Operations should document 401 Unauthorized responses"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: truthy

  uscis-json-content-type:
    description: USCIS API should use JSON content types
    message: "Request and response bodies must use application/json"
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      field: application/json
      function: truthy

  uscis-version-in-info:
    description: API must specify version
    message: "API must include version information"
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy