Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

merge: resolve conflicts with main (REST R1 and R6)

Guido Boykea59917973c1c
diff --cc .github/workflows/guards.yml
index 93d47ba,b59f7c3..84658dc
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@@ -294,9 -292,10 +294,11 @@@ jobs
spec/requests/api/v1/error_codes_spec.rb
spec/requests/api/v1/idempotency_spec.rb
spec/requests/api/v1/capabilities_spec.rb
+ spec/requests/api/v1/time_session_booking_spec.rb
+ spec/requests/api/v1/ticket_view_spec.rb
spec/requests/api/v1/people_spec.rb
spec/requests/api/people_parity_spec.rb
+ spec/requests/api/v1/post_comment_format_spec.rb
spec/models/codebase_import_mapping_spec.rb
spec/services/codebase_import/time_session_importer_spec.rb
spec/services/codebase_import/duplicate_prevention_spec.rb
diff --cc app/controllers/api/v1/posts_controller.rb
index af7971e,93ce634..73d6d89
--- a/app/controllers/api/v1/posts_controller.rb
+++ b/app/controllers/api/v1/posts_controller.rb
@@@ -33,48 -26,33 +33,64 @@@ module Ap
end
end
+ # GET /api/v1/tickets/:ticket_id/posts/:id
+ #
+ # One comment, whole, in the shape the ticket view lists it. Out of the
+ # reader's readable comments of THIS ticket (Tickets::Reading#post): a
+ # hidden private comment, a comment of another ticket and a missing one
+ # answer the same 404 as an unreadable ticket.
+ def show
+ with_readable_ticket(params[:ticket_id]) do |ticket|
+ post = Tickets::Reading.new(serializer: Tickets::Serializer.new(current_user: current_user))
+ .post(ticket, params[:id])
+ raise ActiveRecord::RecordNotFound if post.nil?
+
+ render json: { data: post }
+ end
+ end
+
private
- def post_attributes
- attributes = { is_private: [true, 'true'].include?(post_params[:is_private]),
- visible_to_user_id: post_params[:visible_to_user_id] }
- attributes[:content] = post_params[:body] if post_params[:body].present?
- attributes
+ # Without format (and with html) an empty body stays the model's refusal,
+ # answered after the write check with every message the model has: the
+ # answer this endpoint gave before R3a, which existing callers read. A
+ # plain body that converts to nothing is the rule's refusal.
+ def refused_here?(comment)
+ comment.refused? && (comment.plain? || comment.refusal != :body_empty)
+ end
+
+ def render_comment_refusal(refusal)
+ render_error(error: 'validation_failed', errors: [I18n.t("services.post_comment.#{refusal}")],
+ status: :unprocessable_entity)
end
- def post_params
- params.require(:post).permit(:body, :is_private, :visible_to_user_id)
+ # A failure the actor did not expect (BaseActor answers :internal_error
+ # where it does not re-raise) is no refusal of the input: a 500 without the
+ # exception's text, which may name the database. Every other failure
+ # answers as it always did.
+ def render_comment_failure(result)
+ return render_error(error: 'internal_error', status: :internal_server_error) if result.code == :internal_error
+
+ render_error(error: 'validation_failed', errors: result.errors, status: :unprocessable_entity)
+ end
+
+ # The format goes to the rule raw, not through permit: strong parameters
+ # drop a list or an object, which would have written the comment as html.
+ # Given, it goes as it came (null included); absent, it is html. It is
+ # permitted all the same, so a plain comment logs no unpermitted parameter.
+ def comment_input
+ input = params.require(:post)
+ # A post that is no object (post=text) answers like a missing one.
+ raise ActionController::ParameterMissing, :post unless input.is_a?(ActionController::Parameters)
+
+ permitted = input.permit(:body, :format, :is_private, :visible_to_user_id)
+ body = permitted[:body]
+ # A JSON false was no body before R3a (the old gate was body.present?),
+ # while true and numbers were their text; the rule would write "false".
+ body = nil if body == false
+ fields = { body: body, is_private: permitted[:is_private], visible_to_user_id: permitted[:visible_to_user_id] }
+ fields[:format] = input[:format] if input.key?(:format)
+ fields
end
def serialize(post)
diff --cc app/services/api/v1/capabilities.rb
index 02b3d05,a65aeca..2ab8cae
--- a/app/services/api/v1/capabilities.rb
+++ b/app/services/api/v1/capabilities.rb
@@@ -14,9 -14,10 +14,10 @@@ module Ap
module V1
module Capabilities
# Minor for an additive change (a new endpoint, field or capability), major
- # never: an existing name, field or meaning does not change. 1.2.0: people.list and
- # people.show (People S3b). 1.3.0: posts.plain (REST R3a).
- API_VERSION = '1.3.0'
+ # never: an existing name, field or meaning does not change. 1.2.0 added
+ # the People API; 1.3.0 added the REST ticket view (R1); 1.4.0 adds
- # time_sessions.book (R6).
- API_VERSION = '1.4.0'
++ # time_sessions.book (R6); 1.5.0 adds posts.plain (R3a).
++ API_VERSION = '1.5.0'
# name => [verb, path as the router spells it]
ENDPOINTS = {
@@@ -43,10 -46,11 +46,13 @@@
}.freeze
# Abilities that are not one endpoint: `idempotency` (the Idempotency-Key
-- # header on every write, D7), `error_codes` (`code` on every error body, D6)
- # and `posts.plain` (posts.create takes post[format] html or plain, by the
- # and `tickets.paging` (the opt-in pages of comments and attachments on
- # tickets.show and tickets.by_number, R1), and `time_sessions.book`
- # (shared duration/date validation and actor-backed booking, R6).
- FEATURES = %w[idempotency error_codes tickets.paging time_sessions.book].freeze
++ # header on every write, D7), `error_codes` (`code` on every error body, D6),
++ # `tickets.paging` (the opt-in pages of comments and attachments on
++ # tickets.show and tickets.by_number, R1), `time_sessions.book`
++ # (shared duration/date validation and actor-backed booking, R6), and
++ # `posts.plain` (posts.create takes post[format] html or plain, by the
+ # rule the MCP tool post_comment writes by, Posts::Comment; R3a).
- FEATURES = %w[idempotency error_codes posts.plain].freeze
++ FEATURES = %w[idempotency error_codes tickets.paging time_sessions.book posts.plain].freeze
def self.names
(ENDPOINTS.keys + FEATURES).sort
diff --cc spec/contracts/mcp_contract_recorder.rb
index 48dfef3,af98e1a..0b807e8
--- a/spec/contracts/mcp_contract_recorder.rb
+++ b/spec/contracts/mcp_contract_recorder.rb
@@@ -540,9 -540,10 +540,13 @@@ module McpContrac
# People S3b, appended last: the directory of people_world, made before the MCP calls.
'GET /api/v1/organisations/:organisation_id/people' => rest_people_list_calls,
'GET /api/v1/organisations/:organisation_id/people/:id' => rest_people_show_calls,
+ # REST R1: the ticket view without MCP.
+ 'ticket_view' => rest_ticket_view_calls,
+ # REST R6 runs after the reads above, so its bookings do not change their answers.
- 'POST /api/v1/tickets/:ticket_id/time_sessions' => rest_booking_calls
++ 'POST /api/v1/tickets/:ticket_id/time_sessions' => rest_booking_calls,
+ # REST R3a (cli_rest_plan R3 a), appended last: its comments land on the
+ # login ticket after every answer above, without advancing the clock.
+ 'POST /api/v1/tickets/:ticket_id/posts' => rest_comment_calls
}
end
diff --cc spec/fixtures/mcp_contract.json
index 04ce9a0,400a067..1fd50c9
--- a/spec/fixtures/mcp_contract.json
+++ b/spec/fixtures/mcp_contract.json
@@@ -1,9 -1,9 +1,9 @@@
{
"header": {
"regenerate": "RAILS_ENV=test bin/rails mcp:contract",
- "core_commit": "fa34b08abd15cca2628402543c953cd075a26c77",
- "core_commit": "8da6fd8e1a6e30aec8fa2620118017cf36b68d97",
++ "core_commit": "1a16f823f40cab62f11c3e5c929a6912bda0c95b",
"core_dirty": true,
- "contract_sha256": "a4c77ae287c11f6984df3d0451d379150f5af5e1c7322fff9b0e55213b2ad865"
- "contract_sha256": "1ef1b7500cbe132f2917f4943c225aa9de71903b821aab523484bc6a032ac7a7"
++ "contract_sha256": "80e07918e69c341f6079cc26d11f2144c73593178faa6cde0d6d616058c1f282"
},
"contract": {
"mcp": {
@@@ -3654,7 -3654,7 +3654,7 @@@
"all_projects": true
}
],
- "api_version": "1.3.0",
- "api_version": "1.4.0",
++ "api_version": "1.5.0",
"capabilities": [
"error_codes",
"idempotency",
@@@ -3667,7 -3667,7 +3667,8 @@@
"people.list",
"people.show",
"posts.create",
+ "posts.plain",
+ "posts.show",
"projects.list",
"projects.ticket_attribute_definitions",
"tickets.activities",
@@@ -3714,7 -3717,7 +3718,7 @@@
"all_projects": true
}
],
- "api_version": "1.3.0",
- "api_version": "1.4.0",
++ "api_version": "1.5.0",
"capabilities": [
"error_codes",
"idempotency",
@@@ -3727,7 -3730,7 +3731,8 @@@
"people.list",
"people.show",
"posts.create",
+ "posts.plain",
+ "posts.show",
"projects.list",
"projects.ticket_attribute_definitions",
"tickets.activities",
@@@ -4597,417 -4603,781 +4605,1193 @@@
}
}
},
+ "ticket_view": {
+ "list": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000031/tickets?assignee=00000000-0000-4000-8000-000000000012"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": [
+ {
+ "id": "00000000-0000-4000-8000-000000000041",
+ "number": 1,
+ "title": "Login bricht ab",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000013",
+ "name": "Carla Conrad"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "created_at": "2026-01-05T09:21:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ ],
+ "meta": {
+ "page": 1,
+ "per_page": 25,
+ "total": 1,
+ "available_statuses": [
+ "new",
+ "in_progress",
+ "resolved",
+ "closed",
+ "backlog"
+ ]
+ }
+ }
+ }
+ },
+ "show": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000042"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000042",
+ "number": 2,
+ "title": "Export als CSV und XLSX",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ "created_at": "2026-01-05T09:22:00Z",
+ "updated_at": "2026-01-05T09:36:00Z",
+ "summary": null,
+ "description_html": "Spalten wie in der Liste.",
+ "description_text": "Spalten wie in der Liste.",
+ "custom_attributes": {
+ "status": "in_progress",
+ "priority": "normal"
+ },
+ "project": {
+ "id": "00000000-0000-4000-8000-000000000031",
+ "name": "Website-Relaunch"
+ },
+ "posts": []
+ },
+ "permissions": {
+ "is_account_admin": false,
+ "tickets": {
+ "read": true,
+ "write": true
+ },
+ "documents": {
+ "read": false,
+ "write": false
+ },
+ "posts": {
+ "can_create": true,
+ "can_update_own": true,
+ "can_destroy_own": true
+ },
+ "time_sessions": {
+ "can_view_own": true,
+ "can_view_all": false,
+ "can_create_own": true,
+ "can_edit_own": true,
+ "can_edit_all": false,
+ "can_delete_own": true,
+ "can_delete_all": false
+ },
+ "activities": {
+ "read": true
+ }
+ }
+ }
+ }
+ },
+ "show_paged": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041?posts_per_page=1&posts_page=2&attachments_page=1"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000041",
+ "number": 1,
+ "title": "Login bricht ab",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000013",
+ "name": "Carla Conrad"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "created_at": "2026-01-05T09:21:00Z",
+ "updated_at": "2026-01-05T09:36:00Z",
+ "summary": null,
+ "description_html": "Nach dem Absenden bleibt die Seite weiß.",
+ "description_text": "Nach dem Absenden bleibt die Seite weiß.",
+ "custom_attributes": {
+ "status": "in_progress",
+ "priority": "high"
+ },
+ "project": {
+ "id": "00000000-0000-4000-8000-000000000031",
+ "name": "Website-Relaunch"
+ },
+ "posts": [
+ {
+ "id": "00000000-0000-4000-8000-000000000052",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "Ich schaue es mir an.",
+ "body_text": "Ich schaue es mir an.",
+ "is_private": false,
+ "attachments_count": 0,
+ "created_at": "2026-01-05T09:26:00Z",
+ "updated_at": "2026-01-05T09:26:00Z"
+ }
+ ],
+ "posts_total": 7,
+ "posts_truncated": true,
+ "posts_page": 2,
+ "posts_per_page": 1,
+ "posts_pages": 7,
+ "posts_order": "oldest",
+ "attachments": [
+ {
+ "id": "<generated-id-8>",
+ "filename": "test_document.pdf",
+ "content_type": "application/pdf",
+ "byte_size": 452,
+ "text": null,
+ "text_status": "unavailable"
+ }
+ ],
+ "attachments_total": 1,
+ "attachments_truncated": false,
+ "attachments_page": 1,
+ "attachments_pages": 1
+ },
+ "permissions": {
+ "is_account_admin": false,
+ "tickets": {
+ "read": true,
+ "write": true
+ },
+ "documents": {
+ "read": false,
+ "write": false
+ },
+ "posts": {
+ "can_create": true,
+ "can_update_own": true,
+ "can_destroy_own": true
+ },
+ "time_sessions": {
+ "can_view_own": true,
+ "can_view_all": false,
+ "can_create_own": true,
+ "can_edit_own": true,
+ "can_edit_all": false,
+ "can_delete_own": true,
+ "can_delete_all": false
+ },
+ "activities": {
+ "read": true
+ }
+ }
+ }
+ }
+ },
+ "show_invalid_paging": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041?posts_order=random"
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "invalid_input",
+ "code": "invalid_input",
+ "message": "invalid posts_order \"random\" (oldest or newest)"
+ }
+ }
+ },
+ "by_number": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000031/tickets/number/2"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000042",
+ "number": 2,
+ "title": "Export als CSV und XLSX",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ "created_at": "2026-01-05T09:22:00Z",
+ "updated_at": "2026-01-05T09:36:00Z",
+ "summary": null,
+ "description_html": "Spalten wie in der Liste.",
+ "description_text": "Spalten wie in der Liste.",
+ "custom_attributes": {
+ "status": "in_progress",
+ "priority": "normal"
+ },
+ "project": {
+ "id": "00000000-0000-4000-8000-000000000031",
+ "name": "Website-Relaunch"
+ },
+ "posts": []
+ },
+ "permissions": {
+ "is_account_admin": false,
+ "tickets": {
+ "read": true,
+ "write": true
+ },
+ "documents": {
+ "read": false,
+ "write": false
+ },
+ "posts": {
+ "can_create": true,
+ "can_update_own": true,
+ "can_destroy_own": true
+ },
+ "time_sessions": {
+ "can_view_own": true,
+ "can_view_all": false,
+ "can_create_own": true,
+ "can_edit_own": true,
+ "can_edit_all": false,
+ "can_delete_own": true,
+ "can_delete_all": false
+ },
+ "activities": {
+ "read": true
+ }
+ }
+ }
+ }
+ },
+ "by_number_not_found": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000031/tickets/number/999"
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "by_number_hidden": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000033/tickets/number/1"
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "post": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts/00000000-0000-4000-8000-000000000051"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000051",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ "body_html": "Tritt nur in Safari auf.",
+ "body_text": "Tritt nur in Safari auf.",
+ "is_private": false,
+ "attachments_count": 1,
+ "created_at": "2026-01-05T09:25:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "post_not_found": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts/00000000-0000-4000-8000-000000000999"
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ }
+ },
+ "POST /api/v1/tickets/:ticket_id/time_sessions": {
+ "ok_minutes_text": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
+ "id": "<generated-id-9>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 30,
+ "description": null,
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "ok_hours_text": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "1:30",
+ "occurred_on": "2026-01-04",
+ "description": "Vertrag"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
+ "id": "<generated-id-10>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-04T00:00:00Z",
+ "duration_minutes": 90,
+ "description": "Vertrag",
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "ok_minutes": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_minutes": 45
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
+ "id": "<generated-id-11>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 45,
+ "description": null,
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "invalid_input_no_duration": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "description": "x"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie eine Dauer an (duration_string oder duration_minutes)."
+ ]
+ }
+ }
+ },
+ "invalid_input_both_durations": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30",
+ "duration_minutes": 30
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie die Dauer entweder als duration_string oder als duration_minutes an, nicht beides."
+ ]
+ }
+ }
+ },
+ "invalid_input_date": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30",
+ "occurred_on": "05.01.2026"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Das Datum (occurred_on) ist kein ISO-8601-Datum und kein ISO-8601-Zeitstempel."
+ ]
+ }
+ }
+ },
+ "invalid_input_over_a_day": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "24:01"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Dauer darf höchstens 1440 Minuten (24 Stunden) betragen"
+ ]
+ }
+ }
+ },
+ "not_found": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000999/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "hidden": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000043/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "forbidden": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000044/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 403,
+ "body": {
+ "error": "forbidden",
+ "code": "forbidden"
+ }
+ }
+ },
+ "read_only": {
+ "token": "read",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 403,
+ "body": {
+ "error": "forbidden",
+ "code": "read_only"
+ }
+ }
+ },
+ "idempotency_first": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "0:15",
+ "description": "Per REST, einmal."
+ }
+ },
+ "idempotency_key": "contract-rest-book-1"
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
+ "id": "<generated-id-12>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 15,
+ "description": "Per REST, einmal.",
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "idempotency_replay": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "0:15",
+ "description": "Per REST, einmal."
+ }
+ },
+ "idempotency_key": "contract-rest-book-1"
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
+ "id": "<generated-id-12>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 15,
+ "description": "Per REST, einmal.",
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "idempotency_mismatch": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "0:20"
+ }
+ },
+ "idempotency_key": "contract-rest-book-1"
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "idempotency_key_reused",
+ "code": "invalid_input",
+ "message": "idempotency_key already used with different parameters"
+ }
+ }
+ },
+ "invalid_input_minutes": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_minutes": "1.5"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie duration_minutes als ganze Zahl von Minuten an."
+ ]
+ }
+ }
+ }
++ },
+ "POST /api/v1/tickets/:ticket_id/posts": {
+ "html": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "body": "<p>Ein <b>fetter</b> Satz &amp; mehr</p>"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-8>",
++ "id": "<generated-id-13>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "<p>Ein <b>fetter</b> Satz &amp; mehr</p>",
+ "body_text": "Ein fetter Satz & mehr",
+ "is_private": false,
+ "visible_to_user_id": null,
+ "created_at": "2026-01-05T09:36:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "html_named": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "html",
+ "body": "<p>Noch ein <i>Satz</i></p>"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-9>",
++ "id": "<generated-id-14>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "<p>Noch ein <i>Satz</i></p>",
+ "body_text": "Noch ein Satz",
+ "is_private": false,
+ "visible_to_user_id": null,
+ "created_at": "2026-01-05T09:36:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "html_empty": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "body": ""
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Content darf nicht leer sein"
+ ]
+ }
+ }
+ },
+ "plain": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Zeile 1\nZeile 2\n\nAbsatz <b>&"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-10>",
++ "id": "<generated-id-15>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "<p>Zeile 1<br>Zeile 2</p><p>Absatz &lt;b&gt;&amp;</p>",
+ "body_text": "Zeile 1\nZeile 2\n\nAbsatz <b>&",
+ "is_private": false,
+ "visible_to_user_id": null,
+ "created_at": "2026-01-05T09:36:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "plain_private": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "is_private": true,
+ "body": "<privat>"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-11>",
++ "id": "<generated-id-16>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "<p>&lt;privat&gt;</p>",
+ "body_text": "<privat>",
+ "is_private": true,
+ "visible_to_user_id": "00000000-0000-4000-8000-000000000011",
+ "created_at": "2026-01-05T09:36:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "invalid_input_format": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "markdown",
+ "body": "x"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Das Format (post[format]) muss html oder plain sein."
+ ]
+ }
+ }
+ },
+ "invalid_input_empty": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": ""
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie einen Kommentartext (post[body]) an."
+ ]
+ }
+ }
+ },
+ "invalid_input_whitespace": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": " \n "
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie einen Kommentartext (post[body]) an."
+ ]
+ }
+ }
+ },
+ "invalid_input_nul": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "a\u0000b"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Ein Kommentar im Format plain (post[body]) darf keine NUL-Bytes enthalten."
+ ]
+ }
+ }
+ },
+ "not_found": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000999/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Zeile 1\nZeile 2\n\nAbsatz <b>&"
+ }
+ }
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "hidden": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000043/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Zeile 1\nZeile 2\n\nAbsatz <b>&"
+ }
+ }
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "forbidden": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000044/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Zeile 1\nZeile 2\n\nAbsatz <b>&"
+ }
+ }
+ },
+ "response": {
+ "status": 403,
+ "body": {
+ "error": "forbidden",
+ "code": "forbidden"
+ }
+ }
+ },
+ "read_only": {
+ "token": "read",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Zeile 1\nZeile 2\n\nAbsatz <b>&"
+ }
+ }
+ },
+ "response": {
+ "status": 403,
+ "body": {
+ "error": "forbidden",
+ "code": "read_only"
+ }
+ }
+ },
+ "idempotency_first": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Per REST, einmal, als Text."
+ }
+ },
+ "idempotency_key": "contract-rest-comment-1"
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-12>",
++ "id": "<generated-id-17>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "<p>Per REST, einmal, als Text.</p>",
+ "body_text": "Per REST, einmal, als Text.",
+ "is_private": false,
+ "visible_to_user_id": null,
+ "created_at": "2026-01-05T09:36:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "idempotency_replay": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Per REST, einmal, als Text."
+ }
+ },
+ "idempotency_key": "contract-rest-comment-1"
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-12>",
++ "id": "<generated-id-17>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "<p>Per REST, einmal, als Text.</p>",
+ "body_text": "Per REST, einmal, als Text.",
+ "is_private": false,
+ "visible_to_user_id": null,
+ "created_at": "2026-01-05T09:36:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "idempotency_mismatch": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts",
+ "params": {
+ "post": {
+ "format": "plain",
+ "body": "Anderer Text"
+ }
+ },
+ "idempotency_key": "contract-rest-comment-1"
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "idempotency_key_reused",
+ "code": "invalid_input",
+ "message": "idempotency_key already used with different parameters"
+ }
+ }
+ }
}
}
}
diff --cc spec/requests/api/v1/capabilities_spec.rb
index 2b3e9ed,46fa5c8..62a1818
--- a/spec/requests/api/v1/capabilities_spec.rb
+++ b/spec/requests/api/v1/capabilities_spec.rb
@@@ -33,7 -33,7 +33,7 @@@ RSpec.describe 'API V1 capabilities', :
it 'names the API version and the capabilities beside the existing fields' do
data = me(token(read_only: false))
- expect(data['api_version']).to eq('1.3.0')
- expect(data['api_version']).to eq('1.4.0')
++ expect(data['api_version']).to eq('1.5.0')
expect(data['capabilities']).to eq(Api::V1::Capabilities.names)
expect(data.keys).to include('user', 'token', 'scoped_organisations')
end
@@@ -47,7 -47,7 +47,7 @@@
'me.show', 'organisations.list', 'projects.list', 'tickets.list', 'tickets.create', 'tickets.show',
'tickets.update', 'tickets.attachments', 'posts.create', 'time_sessions.create',
'notifications.list', 'notifications.mark_as_read', 'people.list', 'people.show', 'idempotency', 'error_codes',
- 'posts.plain'
- 'tickets.by_number', 'posts.show', 'tickets.paging', 'time_sessions.book'
++ 'tickets.by_number', 'posts.show', 'tickets.paging', 'time_sessions.book', 'posts.plain'
)
end