Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(TextToImage): Set better attribute for routes
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Oct 15, 2025
commit a5ce35ac84635c0ea296995bf8d2df01549252bd
10 changes: 4 additions & 6 deletions core/Controller/TextToImageApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
Expand Down Expand Up @@ -54,7 +53,7 @@ public function __construct(
*
* 200: Returns availability status
*/
#[PublicPage]
#[NoAdminRequired]
#[ApiRoute(verb: 'GET', url: '/is_available', root: '/text2image')]
public function isAvailable(): DataResponse {
return new DataResponse([
Expand All @@ -75,9 +74,8 @@ public function isAvailable(): DataResponse {
* 200: Task scheduled successfully
* 412: Scheduling task is not possible
*/
#[PublicPage]
#[NoAdminRequired]
#[UserRateLimit(limit: 20, period: 120)]
#[AnonRateLimit(limit: 5, period: 120)]
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/text2image')]
public function schedule(string $input, string $appId, string $identifier = '', int $numberOfImages = 8): DataResponse {
$task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier);
Expand Down Expand Up @@ -111,7 +109,7 @@ public function schedule(string $input, string $appId, string $identifier = '',
* 200: Task returned
* 404: Task not found
*/
#[PublicPage]
#[NoAdminRequired]
#[BruteForceProtection(action: 'text2image')]
#[ApiRoute(verb: 'GET', url: '/task/{id}', root: '/text2image')]
public function getTask(int $id): DataResponse {
Expand Down Expand Up @@ -143,7 +141,7 @@ public function getTask(int $id): DataResponse {
* 200: Image returned
* 404: Task or image not found
*/
#[PublicPage]
#[NoAdminRequired]
#[BruteForceProtection(action: 'text2image')]
#[ApiRoute(verb: 'GET', url: '/task/{id}/image/{index}', root: '/text2image')]
public function getImage(int $id, int $index): DataResponse|FileDisplayResponse {
Expand Down
116 changes: 112 additions & 4 deletions core/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -7199,7 +7199,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7257,6 +7256,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
Expand All @@ -7269,7 +7296,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7438,6 +7464,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
Expand All @@ -7450,7 +7504,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7594,6 +7647,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
},
Expand Down Expand Up @@ -7787,7 +7868,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7914,6 +7994,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
Expand Down
116 changes: 112 additions & 4 deletions core/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7199,7 +7199,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7257,6 +7256,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
Expand All @@ -7269,7 +7296,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7438,6 +7464,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
Expand All @@ -7450,7 +7504,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7594,6 +7647,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
},
Expand Down Expand Up @@ -7787,7 +7868,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
Expand Down Expand Up @@ -7914,6 +7994,34 @@
}
}
}
},
"401": {
"description": "Current user is not logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
Expand Down
Loading
Loading