Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(keys): fix delete schema response #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tharropoulos
Copy link
Contributor

Change Summary

Add a new interface for response schemas after deletion, as the API only returns the id of the API key instead of the whole object.

❯ curl -k "http://localhost:8108/keys/15" \
      -X DELETE \
      -H "Content-Type: application/json" \
      -H "X-TYPESENSE-API-KEY: ${TYPESENSE-API-KEY}" \
{"id":15} // Nothing other than the id of the key

This is part of a larger problem regarding the OpenAPI spec, as according to it, the 200 response schema of a API Key DELETE request is defined as:

  /keys/{keyId}:
    delete:
      tags:
        - keys
      summary: Delete an API key given its ID.
      operationId: deleteKey
      parameters:
        - name: keyId
          in: path
          description: The ID of the key to delete
          required: true
          schema:
            type: integer
            format: int64
      responses:
        200:
          description: The key referenced by the ID
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiKey"

Where the ApiKey schema is defined as:

    ApiKeySchema:
      type: object
      required:
        - actions
        - collections
        - description
      properties:
        value:
          type: string
        description:
          type: string
        actions:
          type: array
          items:
            type: string
        collections:
          type: array
          items:
            type: string
        expires_at:
          type: integer
          format: int64
    ApiKey:
      allOf:
        - $ref: "#/components/schemas/ApiKeySchema"
        - type: object
          properties:
            id:
              type: integer
              format: int64
              readOnly: true
            value_prefix:
              type: string
              readOnly: true

PR Checklist

- Add a new interface for response schemas after deletion, as the api
only returns the id of the api key instead of the whole object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant