Union Pacific · API Governance Rules

Union Pacific API Rules

Spectral linting rules defining API design standards and conventions for Union Pacific.

36 Rules error 13 warn 18 info 5
View Rules File View on GitHub

Rule Categories

components get info no openapi operation parameter paths query request response rpc schema security servers

Rules

error
info-title-required
$.info
warn
info-title-contains-union-pacific
$.info.title
warn
info-description-required
$.info
error
info-version-required
$.info
error
openapi-version-3
$
error
servers-defined
$
error
servers-https-only
$.servers[*].url
info
paths-camel-case-convention
$.paths[*]~
warn
paths-no-trailing-slash
$.paths[*]~
error
operation-id-required
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-id-camel-case
$.paths[*][get,post,put,patch,delete,head,options].operationId
error
operation-summary-required
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-summary-title-case
$.paths[*][get,post,put,patch,delete,head,options].summary
warn
operation-description-required
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-tags-required
$.paths[*][get,post,put,patch,delete,head,options]
warn
parameter-description-required
$.paths[*][get,post,put,patch,delete].parameters[*]
error
parameter-schema-required
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
request-body-json
$.paths[*][post,put,patch].requestBody.content
warn
request-body-description
$.paths[*][post,put,patch].requestBody
error
response-success-defined
$.paths[*][get,post,put,patch,delete]
error
response-description-required
$.paths[*][get,post,put,patch,delete].responses[*]
warn
response-401-unauthorized
$.paths[*][get,post,put,patch,delete]
info
response-400-bad-request
$.paths[*][post,put,patch]
warn
schema-property-camel-case
$.components.schemas[*].properties[*]~
warn
schema-description-required
$.components.schemas[*]
error
security-schemes-defined
$.components
warn
security-oauth2-present
$.components.securitySchemes[*]
error
get-no-request-body
$.paths[*].get
info
rpc-style-post
$.paths[?(@property =~ /release|order|cancel/)][*]
warn
no-empty-descriptions
$..description
error
components-schemas-defined
$.components
warn
servers-expected-domain
Server URLs should be on the up.com domain.
$.servers[*].url
info
query-params-casing
Query parameters should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
operation-documents-401
Operations should document a 401 response (documented on 100% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses

Spectral Ruleset

Raw ↑
# union-pacific — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 1/1 servers on up.com
#   - query-params-casing: camel @ 52% (n=21)
#   - operationid-casing: camel @ 100% (n=14)
#   - schema-names-casing: pascal @ 100% (n=14)
#   - schema-properties-casing: snake @ 52% (n=83)
#   - operation-documents-401: 100% adherence
#   - merge: kept 31 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, query-params-casing, schema-names-casing, schema-properties-casing, operation-documents-401
extends:
  - spectral:oas
rules:
  info-title-required:
    message: API info title is required
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-title-contains-union-pacific:
    message: API title should reference Union Pacific
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: (?i)union.pacific
  info-description-required:
    message: API info description is required
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    message: API info version is required
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    message: OpenAPI version must be 3.x
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-defined:
    message: At least one server must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https-only:
    message: Server URLs must use HTTPS
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-camel-case-convention:
    message: Paths use camelCase or lowercase for resource names (Union Pacific convention)
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-zA-Z0-9_{}/-]+)+$
  paths-no-trailing-slash:
    message: Paths must not end with a trailing slash
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  operation-id-required:
    message: Every operation must have an operationId
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: operationId
      function: truthy
  operation-id-camel-case:
    message: operationId should use camelCase (Union Pacific convention)
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]+$
  operation-summary-required:
    message: Every operation must have a summary
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: summary
      function: truthy
  operation-summary-title-case:
    message: Operation summaries should use Title Case
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z]
  operation-description-required:
    message: Every operation should have a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: description
      function: truthy
  operation-tags-required:
    message: Every operation should have at least one tag
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: tags
      function: truthy
  parameter-description-required:
    message: All parameters should have descriptions
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  parameter-schema-required:
    message: All parameters must have a schema
    severity: error
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: schema
      function: truthy
  request-body-json:
    message: Request bodies should use application/json content type
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1
  request-body-description:
    message: Request bodies should have a description
    severity: warn
    given: $.paths[*][post,put,patch].requestBody
    then:
      field: description
      function: truthy
  response-success-defined:
    message: Every operation must define at least one 2xx success response
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses
      function: truthy
  response-description-required:
    message: All responses must have a description
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  response-401-unauthorized:
    message: Protected operations should define 401 Unauthorized response
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses.401
      function: truthy
  response-400-bad-request:
    message: Write operations should define 400 Bad Request response
    severity: info
    given: $.paths[*][post,put,patch]
    then:
      field: responses.400
      function: truthy
  schema-property-camel-case:
    message: Schema properties should use camelCase (Union Pacific convention)
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  schema-description-required:
    message: Top-level component schemas should have descriptions
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  security-schemes-defined:
    message: Security schemes must be defined
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-oauth2-present:
    message: Union Pacific uses OAuth 2.0 Client Credentials authentication
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
        - oauth2
  get-no-request-body:
    message: GET operations must not have a request body
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  rpc-style-post:
    message: RPC-style action operations (releaseShipment, orderEquipment, cancelRequest) should use POST
      method
    severity: info
    given: $.paths[?(@property =~ /release|order|cancel/)][*]
    then:
      function: truthy
  no-empty-descriptions:
    message: Descriptions must not be empty strings
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  components-schemas-defined:
    message: Components schemas section should be defined
    severity: error
    given: $.components
    then:
      field: schemas
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the up.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: up\.com
  query-params-casing:
    description: Query parameters should be camelCase (the dominant convention in this API).
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: camel
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  operation-documents-401:
    description: Operations should document a 401 response (documented on 100% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy