Take a module route's copies and printer in its JSON body
API inputs go in the JSON body, never in query parameters (owner,
2026-12-01; design.md, "Inputs go in the JSON body"). The module routes
took copies and printer in the query, beside a body that was the
module's payload alone.
The body of POST /api/v1/print/{module} and /api/v1/preview/{module}
now holds the payload under payload, with copies and printer beside it:
{"payload": {...}, "copies": 2, "printer": "default"}. A module may name
its payload's fields as it likes, since none can collide with copies or
printer; that matters for ntfy's messages and for any module that takes
another system's JSON. The body is decoded strictly, and its problems
are answered at once as invalid_payload, each named by its path in the
body: copies, or, once the body is right, payload.done[0] for one the
module finds. A field named body is quoted, "body", so it is never
taken for a problem with the whole body. copies takes 0-5, as a job's
does, 0 meaning one. A query string on these routes gets 400
invalid_query, now worded "query parameters are not accepted".
The ntfy client recipes in docs/api.md wrap $NTFY_RAW in the body. The
Windows command was run here through cmd.exe and PowerShell, and the
printf of the Linux one in sh, each with a message holding quotes, & and
%; neither ran under an ntfy client. No tag carries the module query, so
the 0.2.0 entries in the CHANGELOG change in place (owner, 2026-12-01).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cbac0b5f03
commit
9e829bfce7
16 files changed
+336
-217
No files matched your search
+29
-45
@@ -274,7 +274,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"details": {
|
||||
"description": "details lists every problem when a job fails validation (invalid_job), a module payload is invalid (invalid_payload) or a module builds an invalid receipt (module_failed). A job problem names the element by its path, e.g. elements[0].children[3] (qr); a payload problem names the field, e.g. done[0].",
|
||||
"description": "details lists every problem when a job fails validation (invalid_job), a module route's body or payload is invalid (invalid_payload) or a module builds an invalid receipt (module_failed). A job problem names the element by its path, e.g. elements[0].children[3] (qr); a module route's problem names the field by its path in the body, e.g. payload.done[0] or copies.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -471,8 +471,28 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"ModulePayload": {
|
||||
"description": "ModulePayload is a module's payload: a JSON object whose fields the module defines, such as a note's title, text and items.",
|
||||
"ModuleRequest": {
|
||||
"additionalProperties": false,
|
||||
"description": "ModuleRequest is the body of the module routes: the module's payload, and the copies to print and the printer to print them on.",
|
||||
"properties": {
|
||||
"copies": {
|
||||
"description": "copies is how many times the receipt is printed, each with its own cut. Zero means one.",
|
||||
"maximum": 5,
|
||||
"minimum": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"payload": {
|
||||
"description": "payload is the module's payload: a JSON object whose fields the module defines, such as a note's title, text and items.",
|
||||
"type": "object"
|
||||
},
|
||||
"printer": {
|
||||
"description": "printer is reserved for a second printer: only default is accepted, and an empty name means it.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"payload"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"NtfyHealth": {
|
||||
@@ -1162,7 +1182,7 @@
|
||||
},
|
||||
"/api/v1/preview/{module}": {
|
||||
"post": {
|
||||
"description": "Builds the receipt as /api/v1/print/{module} does and answers as /api/v1/preview does: JSON with the lines' styles when the Accept header prefers application/json to text/plain, and plain text otherwise. It prints nothing and fetches no images.",
|
||||
"description": "Builds the receipt from the same body as /api/v1/print/{module} and answers as /api/v1/preview does: JSON with the lines' styles when the Accept header prefers application/json to text/plain, and plain text otherwise. It prints nothing and fetches no images.",
|
||||
"operationId": "previewModule",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -1173,31 +1193,13 @@
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "How many copies to print, each cut separately: a whole number, 1-5. Default 1.",
|
||||
"in": "query",
|
||||
"name": "copies",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Reserved for a second printer: only default is accepted. Any other query parameter is refused.",
|
||||
"in": "query",
|
||||
"name": "printer",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModulePayload"
|
||||
"$ref": "#/components/schemas/ModuleRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1230,7 +1232,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: invalid query parameter; unknown_printer: unknown printer.",
|
||||
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: query parameters are not accepted; unknown_printer: unknown printer.",
|
||||
"x-uberbringer-codes": [
|
||||
"invalid_payload",
|
||||
"invalid_query",
|
||||
@@ -1523,7 +1525,7 @@
|
||||
},
|
||||
"/api/v1/print/{module}": {
|
||||
"post": {
|
||||
"description": "The module named in the path builds a receipt from the body, its own payload. note and notify decode it strictly: an unknown field or one of the wrong type is refused, with every problem listed; ntfy ignores the fields it does not know. The receipt is then validated and queued as on /api/v1/print. A module with nothing to print answers 204. A token limited to modules (uberbringer token --modules) may use only the modules it names.",
|
||||
"description": "The module named in the path builds a receipt from the body's payload, a JSON object whose fields the module defines; copies and printer sit beside it. The body is decoded strictly, and so are the payloads of note and notify: an unknown field or one of the wrong type is refused, with every problem listed. ntfy ignores the payload fields it does not know. The receipt is then validated and queued as on /api/v1/print. A module with nothing to print answers 204. A token limited to modules (uberbringer token --modules) may use only the modules it names.",
|
||||
"operationId": "printModule",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -1534,31 +1536,13 @@
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "How many copies to print, each cut separately: a whole number, 1-5. Default 1.",
|
||||
"in": "query",
|
||||
"name": "copies",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Reserved for a second printer: only default is accepted. Any other query parameter is refused.",
|
||||
"in": "query",
|
||||
"name": "printer",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModulePayload"
|
||||
"$ref": "#/components/schemas/ModuleRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1594,7 +1578,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: invalid query parameter; unknown_printer: unknown printer.",
|
||||
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: query parameters are not accepted; unknown_printer: unknown printer.",
|
||||
"x-uberbringer-codes": [
|
||||
"invalid_payload",
|
||||
"invalid_query",
|
||||
|
||||
Reference in new issue
Block a user