Python - Flask - Connexion - Swagger - OpenAPI - How can I hide specific endpoint spec?

Viewed 855

Use case: Front end hits /openapi.json and gets the specs. It uses this response to populate a docs page.

The openapi.yml looks like:

openapi: 3.0.0
info:
  title: An API. 
  version: 0.1.0
  description: A description.
paths:
  /status-check:
    $ref: '...'

  /foo/auth:
    description: A descrioption.
    get:
      operationId: foo.foo1.foo2.function
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  sftp_hostname:
                    type: string
                  ssh_keys:
                    type: array
                    items:
                      type: string
        '404':
          description: A description.
        '500':
          description: A description.

What if you don't want to populate the specs of one of the paths in the docs page? In the case above, what if I don't want the front end to receive info about the /foo/auth endpoint?

You can disable serving the spec https://github.com/zalando/connexion#swagger-json but I couldn't find anything (e.g. a flag) to hide the spec of a specific endpoint.

0 Answers
Related