Skip to content

Write endpoints: POST/PUT/DELETE /api/v1/quotes #16

Description

@DutchJaFO

Context

v3 adds write capability to the REST API. These endpoints are the backend for the Blazor management UI and are also directly usable by API clients.

All write endpoints require API key authentication (see #15).

Endpoints

Method Path Description
POST /api/v1/quotes Create a new quote
PUT /api/v1/quotes/{id} Replace an existing quote
DELETE /api/v1/quotes/{id} Delete a quote

A PATCH endpoint (partial update) is out of scope for now — PUT replaces the full resource.

Input contract

POST and PUT accept a JSON body matching the quote schema. Required fields: quote, source, type. Optional: character, author, date, originalLanguage, genres, translations.

id is server-generated on POST (UUID v4). On PUT, the id in the path is authoritative; any id in the body is ignored.

Implementation checklist

  • Extend IQuoteService with AddAsync, UpdateAsync, DeleteAsync
  • Implement in SqliteQuoteService using parameterised queries (mandatory — no string concatenation)
  • Add QuoteWriteRequest DTO with validation attributes
  • Register endpoints in QuoteEndpoints.cs (after /search, before /{id} to preserve route priority)
  • Apply API key auth requirement to all three endpoints
  • Return 201 Created with Location header on POST; 200 OK on PUT; 204 No Content on DELETE
  • Return 404 Not Found when PUT or DELETE targets a non-existent id
  • Add [Description] attributes for OpenAPI/Scalar documentation
  • Add endpoint tests using FakeQuoteService and WebApplicationFactory
  • Update README.md, addon/DOCS.md, and QuoteEndpoints.cs descriptions in the same commit

Notes

  • SQL injection prevention is mandatory: all user-supplied values must go through Dapper parameters, never string-formatted into SQL
  • originalLanguage defaults to "en" if omitted
  • genres defaults to [] if omitted
  • translations is optional and may be omitted or empty on initial creation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions