Square · API Governance Rules

Square API Rules

Spectral linting rules defining API design standards and conventions for Square.

36 Rules error 8 warn 19 info 9
View Rules File View on GitHub

Rule Categories

error info no openapi operation parameter path paths query response schema security servers tag

Rules

error
info-title-required
Info title must be present.
$.info
info
info-title-square
Info title should reference Square.
$.info.title
error
info-description-required
Info description must be present.
$.info
warn
info-version-required
Info version must be present.
$.info
info
info-contact-required
A contact object should be provided.
$.info
info
info-license-required
A license object should be provided.
$.info
warn
openapi-version-3
Specification should be OpenAPI 3.x.
$.openapi
warn
paths-versioned
Square Connect resource paths should be versioned under /v2/ (or legacy /v1/).
$.paths[*]~
warn
paths-no-trailing-slash
Paths should not end with a trailing slash.
$.paths[*]~
warn
paths-lowercase
Path segments should be lowercase (snake_case path params allowed).
$.paths[*]~
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-pascalcase
Square operationIds use PascalCase (e.g. CreatePayment, ListLocations).
$.paths[*][get,post,put,patch,delete].operationId
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-square-prefix
Operation summaries should begin with the provider name "Square".
$.paths[*][get,post,put,patch,delete].summary
info
operation-description-present
Operations should have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Every operation must have tags.
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
Parameters should have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
parameter-name-snakecase
Query and path parameters should use snake_case.
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query' || @.in=='path')].name
error
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
response-2xx-required
Operations should define at least one 2xx success response.
$.paths[*][get,post,put,patch,delete].responses
info
response-json-content
Responses should serve application/json.
$.paths[*][get,post,put,patch,delete].responses[*].content
warn
schema-property-snakecase
Square schema properties use snake_case.
$.components.schemas[*].properties[*]~
info
schema-type-defined
Schema properties should declare a type or reference.
$.components.schemas[*].properties[*]
warn
security-schemes-defined
Security schemes must be defined under components.
$.components
info
security-oauth2-present
Square uses OAuth 2.0; an oauth2 security scheme should be present.
$.components.securitySchemes
info
tag-name-titlecase
Tag names should be PascalCase / Title Case (e.g. Payments, GiftCards).
$.tags[*].name
error
no-empty-descriptions
Descriptions must not be empty.
$..description
info
operation-examples-encouraged
Operations are encouraged to provide examples for mock servers (Microcks).
$.paths[*][get,post,put,patch,delete]
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the squareup.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
query-params-casing
Query parameters should be snake_case (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
warn
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
operation-security-required
Every operation should declare its security requirements.
$.paths[*][get,post,put,patch,delete]
warn
error-schema-defined
A shared error schema (Error) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# square — 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 squareup.com
#   - path-params-casing: snake @ 100% (n=198)
#   - query-params-casing: snake @ 100% (n=197)
#   - operationid-casing: pascal @ 100% (n=305)
#   - schema-names-casing: pascal @ 100% (n=1220)
#   - schema-properties-casing: snake @ 100% (n=3541)
#   - operation-security-required: 305/305 ops declare per-op security
#   - error-schema-defined: Error
#   - pagination params observed: ['count', 'cursor', 'limit']
#   - merge: kept 28 existing, added 8 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, operation-security-required, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info title must be present.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-title-square:
    description: Info title should reference Square.
    severity: info
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: (?i)square
  info-description-required:
    description: Info description must be present.
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info version must be present.
    severity: warn
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    description: A contact object should be provided.
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy
  info-license-required:
    description: A license object should be provided.
    severity: info
    given: $.info
    then:
      field: license
      function: truthy
  openapi-version-3:
    description: Specification should be OpenAPI 3.x.
    severity: warn
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.
  paths-versioned:
    description: Square Connect resource paths should be versioned under /v2/ (or legacy /v1/).
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/v[12]/
  paths-no-trailing-slash:
    description: Paths should not end with a trailing slash.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: .+/$
  paths-lowercase:
    description: Path segments should be lowercase (snake_case path params allowed).
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z0-9/_{}.-]+$
  operation-operationid-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-operationid-pascalcase:
    description: Square operationIds use PascalCase (e.g. CreatePayment, ListLocations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]+$
  operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-summary-square-prefix:
    description: Operation summaries should begin with the provider name "Square".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^Square '
  operation-description-present:
    description: Operations should have a description.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: Every operation must have tags.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: Parameters should have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  parameter-name-snakecase:
    description: Query and path parameters should use snake_case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query' || @.in=='path')].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  response-description-required:
    description: Every response must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  response-2xx-required:
    description: Operations should define at least one 2xx success response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '200'
      function: truthy
  response-json-content:
    description: Responses should serve application/json.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses[*].content
    then:
      field: application/json
      function: truthy
  schema-property-snakecase:
    description: Square schema properties use snake_case.
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  schema-type-defined:
    description: Schema properties should declare a type or reference.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      function: xor
      functionOptions:
        properties:
        - type
        - $ref
        - allOf
        - oneOf
        - anyOf
  security-schemes-defined:
    description: Security schemes must be defined under components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-oauth2-present:
    description: Square uses OAuth 2.0; an oauth2 security scheme should be present.
    severity: info
    given: $.components.securitySchemes
    then:
      field: oauth2
      function: truthy
  tag-name-titlecase:
    description: Tag names should be PascalCase / Title Case (e.g. Payments, GiftCards).
    severity: info
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z]
  no-empty-descriptions:
    description: Descriptions must not be empty.
    severity: error
    given: $..description
    then:
      function: truthy
  operation-examples-encouraged:
    description: Operations are encouraged to provide examples for mock servers (Microcks).
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the squareup.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: squareup\.com
  path-params-casing:
    description: Path parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: snake
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  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: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  operation-security-required:
    description: Every operation should declare its security requirements.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      function: truthy
  error-schema-defined:
    description: A shared error schema (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy