openapi: 3.1.0
info:
  title: NerdTools API
  version: 1.0.0
servers:
  - url: https://nerdtools.co.uk/api/v1
security:
  - bearerAuth: []
paths:
  /dns/records:
    get:
      summary: Resolve DNS records
      parameters:
        - {name: domain, in: query, required: true, schema: {type: string}}
        - {name: type, in: query, schema: {type: string, enum: [A, AAAA, CNAME, MX, NS, TXT, SRV, SOA, CAA], default: A}}
      responses:
        '200': {$ref: '#/components/responses/Success'}
        '422': {$ref: '#/components/responses/Error'}
  /dns/caa:
    get: {$ref: '#/components/pathItems/DomainCheck'}
  /email/spf:
    get: {$ref: '#/components/pathItems/DomainCheck'}
  /email/dmarc:
    get: {$ref: '#/components/pathItems/DomainCheck'}
  /email/mx:
    get: {$ref: '#/components/pathItems/DomainCheck'}
  /email/dkim:
    get:
      summary: Check DKIM selectors
      parameters:
        - {name: domain, in: query, required: true, schema: {type: string}}
        - {name: selector, in: query, schema: {type: string}}
      responses:
        '200': {$ref: '#/components/responses/Success'}
components:
  securitySchemes:
    bearerAuth: {type: http, scheme: bearer}
  pathItems:
    DomainCheck:
      summary: Run a DNS-backed domain check
      parameters:
        - {name: domain, in: query, required: true, schema: {type: string}}
      responses:
        '200': {$ref: '#/components/responses/Success'}
        '422': {$ref: '#/components/responses/Error'}
  responses:
    Success:
      description: Successful diagnostic
      content:
        application/json:
          schema: {$ref: '#/components/schemas/Envelope'}
    Error:
      description: Error response
      content:
        application/json:
          schema: {$ref: '#/components/schemas/Envelope'}
  schemas:
    Envelope:
      type: object
      required: [ok, data, error, meta]
      properties:
        ok: {type: boolean}
        data: {type: [object, 'null']}
        error: {type: [object, 'null']}
        meta: {type: object}
