Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid openapi specification #1367

Open
Leptopoda opened this issue Sep 18, 2024 · 0 comments · May be fixed by #1386
Open

Invalid openapi specification #1367

Leptopoda opened this issue Sep 18, 2024 · 0 comments · May be fixed by #1386
Assignees
Labels
2. developing Work in progress bug Something isn't working

Comments

@Leptopoda
Copy link
Member

Leptopoda commented Sep 18, 2024

Steps to reproduce

The openapi spec states that a request to /index.php/apps/tables/api/1/tables/{tableId}/rows/simple returns a List of strings.

tables/openapi.json

Lines 3840 to 3853 in 5cc780c

"responses": {
"200": {
"description": "Row values returned",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},

/**
* List all rows values for a table, first row are the column titles
*
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
* @param int $tableId Table ID
* @param int|null $limit Limit
* @param int|null $offset Offset
* @return DataResponse<Http::STATUS_OK, string[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Row values returned
* 403: No permissions
* 404: Not found
*/
public function indexTableRowsSimple(int $tableId, ?int $limit, ?int $offset): DataResponse {
try {
return new DataResponse($this->v1Api->getData($tableId, $limit, $offset, $this->userId));
} catch (PermissionError $e) {
$this->logger->warning('A permission error occurred: ' . $e->getMessage(), ['exception' => $e]);
$message = ['message' => $e->getMessage()];
return new DataResponse($message, Http::STATUS_FORBIDDEN);
} catch (InternalError|Exception $e) {
$this->logger->error('An internal error or exception occurred: '.$e->getMessage(), ['exception' => $e]);
$message = ['message' => $e->getMessage()];
return new DataResponse($message, Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

But making an actual request returns a List of List of String|int.

[
  [
    "What",
    "How to do",
    "Ease of use",
    "Done"
  ],
  [
    "Open the tables app",
    "Click on tables icon in the menu bar.",
    5,
    "true"
  ],
  [
    "Add your first row",
    "Just click on \"new row\" and enter some data inside of the form. At the end click on the bottom \"save\".",
    5,
    "false"
  ],
  [
    "Edit a row",
    "Hover the mouse over a row you want to edit. Click on the pen on the right side. Maybe you want to add a \"done\" status to this row.",
    5,
    "false"
  ],
  [
    "Add a new column",
    "You can add, remove and adjust columns as you need it. Click on the three-dot-menu on the upper right of this table and choose \"create column\". Fill in the data you want, at least a title and column type.",
    4,
    "false"
  ],
  [
    "Read the docs",
    "If you want to go through the documentation, this can be found here: https://github.com/nextcloud/tables/wiki",
    3,
    "false"
  ]
]

Expected behavior

The spec correctly mentions that the endpoint returns a nested list.

Actual behavior

The spec differs from the actual behavior, making generated api clients fail.

Tables app version

0.8.0

Browser

N.A.

Client operating system

N.A.

Operating system

Linux (Docker

Web server

None

PHP engine version

PHP 8.2

Database

SQLite

Additional info

I also had type issues on other endpoints but didn't debug all of them for now.
I suspect that this issue is broader than just the one endpoint.

@Leptopoda Leptopoda added bug Something isn't working 0. Needs triage Pending approval or rejection. This issue is pending approval. labels Sep 18, 2024
@provokateurin provokateurin self-assigned this Sep 27, 2024
@provokateurin provokateurin added 2. developing Work in progress and removed 0. Needs triage Pending approval or rejection. This issue is pending approval. labels Sep 27, 2024
@provokateurin provokateurin linked a pull request Sep 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants