Skip to content

bump overlay: filtering by endpoints' tags #775

@jamietanna

Description

@jamietanna

As discussed on the APIs You Won't Hate Slack, I've recently been trying to get an Overlay working to do endpoint-level filtering, based on the tags of the given endpoint

(Related: atamano/jsonpathly#12)

Spec:

openapi: 3.1.0
info:
  title: "..."
  description: "..."
  version: 1.0.0

tags:
  - name: Enterprise-Only
    description: |
      ...

paths:
  /metrics:
    get:
      operationId: getPrometheusMetrics
      responses:
        '200':
          description: "..."
          content:
            text/plain:
              schema:
                type: string
  /super/secret:
    get:
      tags:
        - Enterprise-Only
      responses:
        '200':
          description: "..."
          content:
            text/plain:
              schema:
                type: string

Overlay:

overlay: 1.0.0
info:
  title: "..."
  version: 1.0.0
actions:
  # remove the tagged endpoints
  # TODO doesn't work currently `[email protected]`
  - target: $.paths..[?(@.tags && @.tags[*] == 'Enterprise-Only')]
    remove: true

  # remove the top-level tags
  - target: $.tags[?(@.name == 'Enterprise-Only')]
    remove: true

When running:

npx [email protected] overlay openapi.yml overlay.yaml

I would expect /super/secret not to exist, but it does

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions