Apache OpenNLP · API Governance Rules

Apache OpenNLP API Rules

Spectral linting rules defining API design standards and conventions for Apache OpenNLP.

16 Rules error 5 warn 9 info 2
View Rules File View on GitHub

Rule Categories

error info no operation operationid paths request response schema servers

Rules

error
info-title-required
API must have a title
$.info
warn
info-description-required
API must have a description
$.info
error
operation-summary-required
Operations must have summaries
$.paths[*][*]
error
operation-operationId-required
Operations must have operationIds
$.paths[*][*]
warn
operation-tags-required
Operations must have tags
$.paths[*][*]
info
operation-summary-apache-prefix
Summaries should start with Apache OpenNLP
$.paths[*][get,post,put,delete,patch].summary
warn
paths-kebab-case
Path segments should use kebab-case
$.paths[*]~
warn
request-body-content-type
Request bodies should use application/json
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Operations must have a 200 success response
$.paths[*][*].responses
warn
schema-type-defined
Schema properties should have types defined
$.components.schemas[*].properties[*]
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
operationid-casing
Operation IDs should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
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
error-schema-defined
A shared error schema (ErrorResponse) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# apache-opennlp — 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)
#   - operationid-casing: camel @ 82% (n=11)
#   - schema-names-casing: pascal @ 100% (n=19)
#   - schema-properties-casing: snake @ 88% (n=48)
#   - error-schema-defined: ErrorResponse
#   - merge: kept 10 existing, added 6 measured, upgraded 0
#   - added: servers-https-only, operationid-casing, schema-names-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-required:
    description: API must have a title
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: API must have a description
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  operation-summary-required:
    description: Operations must have summaries
    severity: error
    given: $.paths[*][*]
    then:
      field: summary
      function: truthy
  operation-operationId-required:
    description: Operations must have operationIds
    severity: error
    given: $.paths[*][*]
    then:
      field: operationId
      function: truthy
  operation-tags-required:
    description: Operations must have tags
    severity: warn
    given: $.paths[*][*]
    then:
      field: tags
      function: truthy
  operation-summary-apache-prefix:
    description: Summaries should start with Apache OpenNLP
    severity: info
    given: $.paths[*][get,post,put,delete,patch].summary
    then:
      function: pattern
      functionOptions:
        match: ^Apache OpenNLP
  paths-kebab-case:
    description: Path segments should use kebab-case
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9{}-]+)+$
  request-body-content-type:
    description: Request bodies should use application/json
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      function: schema
      functionOptions:
        schema:
          required:
          - application/json
  response-success-required:
    description: Operations must have a 200 success response
    severity: error
    given: $.paths[*][*].responses
    then:
      function: schema
      functionOptions:
        schema:
          required:
          - '200'
  schema-type-defined:
    description: Schema properties should have types defined
    severity: warn
    given: $.components.schemas[*].properties[*]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - type
          - required:
            - $ref
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  operationid-casing:
    description: Operation IDs should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      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: 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: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (ErrorResponse) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorResponse
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy