3636use OCP \AppFramework \Http \Attribute \NoCSRFRequired ;
3737use OCP \AppFramework \Http \Attribute \OpenAPI ;
3838use OCP \AppFramework \Http \DataResponse ;
39+ use OCP \AppFramework \Http \JSONResponse ;
3940use OCP \IL10N ;
4041use OCP \IRequest ;
4142use Psr \Log \LoggerInterface ;
@@ -148,9 +149,9 @@ public function createTable(string $title, ?string $emoji, string $template = 'c
148149 * returns table scheme
149150 *
150151 * @param int $tableId Table ID
151- * @return DataResponse <Http::STATUS_OK, TablesTable, array{'Content-Disposition'?: string,'Content-Type'?: string}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
152+ * @return JSONResponse <Http::STATUS_OK, TablesTable, array{'Content-Disposition': string, 'Content-Type': string}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
152153 *
153- * 200: Table returned
154+ * 200: Scheme returned
154155 * 403: No permissions
155156 * 404: Not found
156157 */
@@ -159,10 +160,19 @@ public function createTable(string $title, ?string $emoji, string $template = 'c
159160 #[CORS ]
160161 #[RequirePermission(permission: Application::PERMISSION_READ , type: Application::NODE_TYPE_TABLE , idParam: 'tableId ' )]
161162 #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT )]
162- public function showScheme (int $ tableId ): DataResponse {
163+ public function showScheme (int $ tableId ): JSONResponse | DataResponse {
163164 try {
164165 $ scheme = $ this ->tableService ->getScheme ($ tableId , $ this ->userId );
165- return new DataResponse ($ scheme ->jsonSerialize (), http::STATUS_OK , ['Content-Disposition ' => 'attachment; filename=" ' . $ scheme ->getTitle () . '.json" ' , 'Content-Type ' => 'application/octet-stream ' ]);
166+ $ filename = $ scheme ->getTitle () . '.json ' ;
167+
168+ return new JSONResponse (
169+ $ scheme ->jsonSerialize (),
170+ Http::STATUS_OK ,
171+ [
172+ 'Content-Disposition ' => 'attachment; filename=" ' . $ filename . '" ' ,
173+ 'Content-Type ' => 'application/json ' ,
174+ ]
175+ );
166176 } catch (PermissionError $ e ) {
167177 $ this ->logger ->warning ('A permission error occurred: ' . $ e ->getMessage ());
168178 $ message = ['message ' => $ e ->getMessage ()];
0 commit comments