Skip to content

Commit 3ce9107

Browse files
authored
fix: standardize nullable refs and correct array items syntax (#1996)
This PR fix two places where docs used non-standard (according to OpenAPI 3.0) spec. Why? I was playing with `oapi-codeget` tool for generation Go client from `openapi.yaml`. Without these changes I wasn't able to generate it. I got these errors: 1. Caused by incorrect ProxyGroup ref ``` $ go tool oapi-codegen openapi.yaml error loading swagger spec in openapi.yaml : failed to load OpenAPI specification: failed to unmarshal data: json error: invalid character 'o' looking for beginning of value, yaml error: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into field Schema.items of type openapi3.Schema ``` 2. Caused by incorrect nullable ActorDefinition ``` $ go tool oapi-codegen openapi.yaml error generating code: error generating type definitions: error generating Go types for component schemas: error converting Schema Build to Go type: error generating Go schema for property 'actorDefinition': error generating type for oneOf: error resolving primitive type: unhandled Schema type: &[null] ``` Details about oapi-codegen: ``` go tool oapi-codegen -version github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen v2.5.0 ``` Places for verification: - https://docs.apify.com/api/v2/actor-build-get -> https://pr-1996.preview.docs.apify.com/api/v2/actor-build-get (added `nullable` label to `ActorDefinition` in schema) - https://docs.apify.com/api/v2/users-me-get -> https://pr-1996.preview.docs.apify.com/api/v2/users-me-get (added object schema for `Proxy` instead of `undefined`)
1 parent 8665595 commit 3ce9107

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apify-api/openapi/components/schemas/actor-builds/Build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ properties:
7272
type: string
7373
example: 0.1.1
7474
actorDefinition:
75-
oneOf:
75+
allOf:
7676
- $ref: "../actors/ActorDefinition.yaml"
77-
- type: "null"
77+
nullable: true
7878
example:
7979
id: HG7ML7M8z78YcAPEB
8080
actId: janedoe~my-actor

apify-api/openapi/components/schemas/users/Proxy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ properties:
1010
groups:
1111
type: array
1212
items:
13-
- $ref: ./ProxyGroup.yaml
13+
$ref: ./ProxyGroup.yaml

0 commit comments

Comments
 (0)