Commit 8fff045
docs(openapi): Autofix OpenAPI spec validation errors (#2707)
## Summary
Autogenerated OpenAPI fixes suggestions based on validation errors
generated from running API integration tests with OpenAPI validator
turned on.
**Error log:**
https://apify-pr-test-env-logs.s3.us-east-1.amazonaws.com/apify/apify-core/27741/api-d6d396f2cd22488c525a27934442252e8901a6b8.log
**apify-core version:**
https://github.com/apify/apify-core/tree/db6c2e4b52c836e0bb45b2e22384c59b66024726
**Stop reason:** All reproducible response-validation specification
errors in the log were fixed (6 unique error signatures across 3 schema
files). Every remaining error in the log is either a known false
positive, an intentional malformed-request test, or an
internal/out-of-scope endpoint, so no further spec fixes are possible.
This PR is stacked on `fix-spec-errors-from-staging`, which already
carries the fixes for errors that cannot be reproduced in the PR test
environment.
## Detailed changes description
### Error fixes
#### Nullable `buildTag` on Actor version endpoints
- **Files:**
`apify-api/openapi/components/schemas/actors/Version.yaml:28`
- **Error:** `Response OpenAPI validation error
{"url":"/v2/actors/{actorId}","method":"GET","statusCode":200,"errors":[{"message":"must
be
string","errorCode":"type.openapi.validation","path":"/response/data/versions/{n}/buildTag"}]}`
— also raised on `GET /v2/actors/{actorId}/versions`
(`/items/{n}/buildTag`), `POST /v2/actors/{actorId}/versions`, `GET
/v2/actors/{actorId}/versions/{versionNumber}` and `PUT
/v2/actors/{actorId}/versions/{versionNumber}` (`/data/buildTag`).
- **Root cause:** A version created without a build tag stores and
returns `buildTag: null`. The request schema already allows `null`, the
value round-trips unchanged through the create/get/update handlers, but
`Version.yaml` declared `buildTag` as a non-nullable `string`. Changed
to `type: [string, "null"]`.
- **Reference:**
https://github.com/apify/apify-core/tree/db6c2e4b52c836e0bb45b2e22384c59b66024726/tests/integration/tests/actor/actors.openapi_response_validation.js#L44
#### Reduced `GET /v2/users/me` response from an Actor run
- **Files:**
`apify-api/openapi/components/schemas/users/UserPrivateInfo.yaml:2`,
`apify-api/openapi/components/schemas/users/Plan.yaml:2`
- **Error:** `Response OpenAPI validation error
{"url":"/v2/users/me","method":"GET","statusCode":200,"errors":[{"message":"must
have required property 'id'","path":"/response/data/id"}, ...
'email','createdAt','profile', and every required field of plan]}`
- **Root cause:** When `/v2/users/me` is accessed from an Actor run
without full access, the handler deletes `id`, `email`, `profile`,
`createdAt` and the full `plan` object, then re-adds `plan` containing
only `availableProxyGroups`. Those properties were all marked `required`
in the spec. Removed `id`, `email`, `profile`, `createdAt` from
`UserPrivateInfo.required` and reduced `Plan.required` to only
`availableProxyGroups` (the single field guaranteed in the reduced
response).
- **Reference:**
https://github.com/apify/apify-core/tree/db6c2e4b52c836e0bb45b2e22384c59b66024726/src/api/src/routes/users/user.ts#L43
#### Optional/nullable `description` and `userFullName` on store Actor
listings
- **Files:**
`apify-api/openapi/components/schemas/store/StoreListActor.yaml:2`
(`required`), `:24` (`userFullName`), `:26` (`description`)
- **Error:** `Response OpenAPI validation error
{"url":"/v2/store","method":"GET","statusCode":200,"errors":[{"message":"must
have required property
'description'","path":"/response/data/items/{n}/description"},{"message":"must
have required property
'userFullName'","path":"/response/data/items/{n}/userFullName"},{"message":"must
be
string","errorCode":"type.openapi.validation","path":"/response/data/items/{n}/userFullName"}]}`
- **Root cause:** `GET /v2/store` (`store_get`) returns `StoreListActor`
items where neither field is guaranteed. In the store index both fields
are set from the owner's profile and become `null` when the owner has no
public profile, and `userFullName` is optional in the `StoreActor` type.
The spec marked both as `required` and typed them as non-nullable
`string`. Removed `userFullName` and `description` from
`StoreListActor.required` and changed both to `type: [string, "null"]`.
- **Reference:**
https://github.com/apify/apify-core/tree/db6c2e4b52c836e0bb45b2e22384c59b66024726/src/packages/actor-server/src/actors/actors_store_index.server.ts#L368
;
https://github.com/apify/apify-core/tree/db6c2e4b52c836e0bb45b2e22384c59b66024726/src/packages/types/src/actor_store.ts#L40
;
https://github.com/apify/apify-core/tree/db6c2e4b52c836e0bb45b2e22384c59b66024726/src/packages/types/src/actor.ts#L299
## Issues
Partially implements: #2286
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e4584b4 commit 8fff045
4 files changed
Lines changed: 4 additions & 28 deletions
File tree
- apify-api/openapi/components/schemas
- actors
- store
- users
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
| |||
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
| 27 | + | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | 3 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 4 | | |
23 | 5 | | |
24 | 6 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | | - | |
6 | | - | |
7 | 4 | | |
8 | 5 | | |
9 | 6 | | |
10 | | - | |
11 | 7 | | |
12 | 8 | | |
13 | 9 | | |
| |||
0 commit comments