Apache Nutch · API Governance Rules

Apache Nutch API Rules

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

33 Rules error 12 warn 19 info 2
View Rules File View on GitHub

Rule Categories

delete get info no openapi operation parameter paths request response schema security servers tags

Rules

error
info-title-required
OpenAPI info must have a title.
$.info
warn
info-description-required
OpenAPI info must have a non-empty description.
$.info
error
info-version-required
OpenAPI info must define a version.
$.info
warn
info-contact-required
OpenAPI info should include contact information.
$.info
warn
info-license-required
OpenAPI info should include license information.
$.info
error
openapi-version-3
Specs must use OpenAPI 3.x.
$
error
servers-defined
At least one server must be defined.
$
warn
servers-description
Each server should have a description.
$.servers[*]
warn
paths-kebab-case
Path segments must use kebab-case (lowercase letters, numbers, hyphens).
$.paths[*]~
warn
paths-no-trailing-slash
Paths should not have trailing slashes (except root).
$.paths[*]~
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-description-required
Every operation should have a description.
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-operationid-camel-case
operationId should use camelCase.
$.paths[*][get,post,put,patch,delete,head,options].operationId
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete,head,options]
info
operation-summary-apache-nutch-prefix
Operation summaries should start with "Apache Nutch".
$.paths[*][get,post,put,patch,delete,head,options].summary
warn
tags-global-defined
Global tags array should be defined.
$
warn
tags-description
Each global tag should have a description.
$.tags[*]
warn
parameter-description-required
Every parameter must have a description.
$.paths[*][get,post,put,patch,delete,head,options].parameters[*]
error
parameter-schema-required
Every parameter must have a schema.
$.paths[*][get,post,put,patch,delete,head,options].parameters[*]
warn
request-body-description
Request bodies should have a description.
$.paths[*][post,put,patch].requestBody
warn
request-body-content-json
Request bodies should support application/json content type.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-401-required
Secured operations should document 401 Unauthorized response.
$.paths[*][get,post,put,patch,delete].responses
info
response-500-defined
Operations should document 500 Internal Server Error response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-description-required
Top-level component schemas should have a description.
$.components.schemas[*]
warn
schema-property-type-required
Schema properties should define a type.
$.components.schemas[*].properties[*]
error
security-schemes-defined
Security schemes must be defined in components.
$.components
warn
security-global-defined
Global security requirements should be defined.
$
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body.
$.paths[*].delete
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# Apache Nutch API Spectral Ruleset
# Enforces conventions observed across the Apache Nutch REST API OpenAPI specification.

rules:

  # INFO / METADATA
  info-title-required:
    description: OpenAPI info must have a title.
    severity: error
    given: "$.info"
    then:
      field: title
      function: truthy

  info-description-required:
    description: OpenAPI info must have a non-empty description.
    severity: warn
    given: "$.info"
    then:
      field: description
      function: truthy

  info-version-required:
    description: OpenAPI info must define a version.
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  info-contact-required:
    description: OpenAPI info should include contact information.
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  info-license-required:
    description: OpenAPI info should include license information.
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    description: Specs must use OpenAPI 3.x.
    severity: error
    given: "$"
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-defined:
    description: At least one server must be defined.
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  servers-description:
    description: Each server should have a description.
    severity: warn
    given: "$.servers[*]"
    then:
      field: description
      function: truthy

  # PATHS — NAMING CONVENTIONS
  paths-kebab-case:
    description: Path segments must use kebab-case (lowercase letters, numbers, hyphens).
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(\\/([a-z0-9][a-z0-9\\-]*|\\{[a-zA-Z0-9_]+\\}))*\\/?$"

  paths-no-trailing-slash:
    description: Paths should not have trailing slashes (except root).
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        notMatch: ".+\\/$"

  # OPERATIONS
  operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,head,options]"
    then:
      field: summary
      function: truthy

  operation-description-required:
    description: Every operation should have a description.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete,head,options]"
    then:
      field: description
      function: truthy

  operation-operationid-required:
    description: Every operation must have an operationId.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,head,options]"
    then:
      field: operationId
      function: truthy

  operation-operationid-camel-case:
    description: operationId should use camelCase.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete,head,options].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  operation-tags-required:
    description: Every operation must have at least one tag.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,head,options]"
    then:
      field: tags
      function: truthy

  operation-summary-apache-nutch-prefix:
    description: Operation summaries should start with "Apache Nutch".
    severity: info
    given: "$.paths[*][get,post,put,patch,delete,head,options].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Apache Nutch "

  # TAGS
  tags-global-defined:
    description: Global tags array should be defined.
    severity: warn
    given: "$"
    then:
      field: tags
      function: truthy

  tags-description:
    description: Each global tag should have a description.
    severity: warn
    given: "$.tags[*]"
    then:
      field: description
      function: truthy

  # PARAMETERS
  parameter-description-required:
    description: Every parameter must have a description.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete,head,options].parameters[*]"
    then:
      field: description
      function: truthy

  parameter-schema-required:
    description: Every parameter must have a schema.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,head,options].parameters[*]"
    then:
      field: schema
      function: truthy

  # REQUEST BODIES
  request-body-description:
    description: Request bodies should have a description.
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody"
    then:
      field: description
      function: truthy

  request-body-content-json:
    description: Request bodies should support application/json content type.
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  # RESPONSES
  response-success-required:
    description: Every operation must define at least one 2xx response.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["200"]
            - required: ["201"]
            - required: ["204"]

  response-401-required:
    description: Secured operations should document 401 Unauthorized response.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required: ["401"]

  response-500-defined:
    description: Operations should document 500 Internal Server Error response.
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required: ["500"]

  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

  # SCHEMAS
  schema-description-required:
    description: Top-level component schemas should have a description.
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  schema-property-type-required:
    description: Schema properties should define a type.
    severity: warn
    given: "$.components.schemas[*].properties[*]"
    then:
      field: type
      function: truthy

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

  security-global-defined:
    description: Global security requirements should be defined.
    severity: warn
    given: "$"
    then:
      field: security
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: "$.paths[*].get"
    then:
      field: requestBody
      function: falsy

  delete-no-request-body:
    description: DELETE operations should not have a request body.
    severity: warn
    given: "$.paths[*].delete"
    then:
      field: requestBody
      function: falsy

  # GENERAL QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: "$..description"
    then:
      function: pattern
      functionOptions:
        match: ".+"