Skip to content

Commit e6975fc

Browse files
feat(api): troubleshooting tests for publishing (#11668)
* feat(api): troubleshooting tests for publishing * formatting * add openapi diff note
1 parent 1fb993b commit e6975fc

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

develop-docs/backend/api/public.mdx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,79 @@ will be triggered to make your changes automatically go live:
410410
makes and merges a PR in `sentry-docs`, which kicks off a deploy via Vercel to
411411
https://docs.sentry.io/api/.
412412

413+
## Troubleshooting API Docs Tests
414+
415+
NOTE: The `openapi-diff` test is supposed to fail when CI runs on your pull request as it is meant to highlight the schema changes. It is not required to merge.
416+
417+
**Problem**: `TypeError: Cannot read properties of null (reading 'type')`
418+
419+
**Solution**: If you have a `ChoiceField` that can be null, make sure you're using the right option. `allow_blank` should be used for textual choices, while `allow_null` should be used for numeric and other non-textual choices.
420+
421+
---
422+
423+
**Problem**: `must have required property '<property_name>'`
424+
```json
425+
{
426+
"type": "Validation",
427+
"message": "must have required property '<property_name>'",
428+
"instancePath": "",
429+
"schemaPath": "#/required",
430+
"keyword": "required",
431+
"params": {
432+
"missingProperty": "<property_name>"
433+
},
434+
"examplePath": "<endpoint_path>"
435+
}
436+
```
437+
438+
**Solution**: Your example response is missing the required property `<property_name>` which is specified by the response class. `<property_name>` should either be made optional in the response class or added to the example response.
439+
440+
---
441+
442+
**Problem**: `must NOT have additional properties`
443+
```json
444+
{
445+
"type": "Validation",
446+
"message": "must NOT have additional properties",
447+
"instancePath": "",
448+
"schemaPath": "#/additionalProperties",
449+
"keyword": "additionalProperties",
450+
"params": {
451+
"additionalProperty": "<property_name>"
452+
},
453+
"examplePath": "<endpoint_path>"
454+
}
455+
```
456+
457+
**Solution**: Your example response includes a property with `<property_name>` that is not included in the response class. This either needs to be added to the response class or removed from the example.
458+
459+
---
460+
461+
**Problem**: `must be <type>`
462+
```json
463+
{
464+
"type": "Validation",
465+
"message": "must be <type>",
466+
"instancePath": "/0/<property_name>",
467+
"schemaPath": "#/items/properties/<property_name>/type",
468+
"keyword": "type",
469+
"params": {
470+
"type": "<type>"
471+
},
472+
"examplePath": "<endpoint_path>"
473+
}
474+
```
475+
476+
**Solution**: The type of the value for a property in your example response does not match the type for the property specified by the response class. The example value or the type of the property in the response class should be fixed.
477+
478+
---
479+
480+
**Problem**: `sentry.apidocs.utils.SentryApiBuildError: projects is not defined by OPENAPI_TAGS in src/sentry/apidocs/build.py for <endpoint title>`
481+
482+
**Solution**: You need to add the endpoint to a [sidebar tab](/backend/api/public/#3-sidebar-tab) with the decorator `@extend_schema(tags=['<section title>'])`.
483+
484+
---
485+
413486
## Requesting an API to be public
414487

415488
Are you a Sentry user who wants an endpoint to be public?
@@ -423,6 +496,7 @@ and add the `Component: API` label.
423496
The team responsible for the endpoint will review the stability of the endpoint. If the endpoint
424497
will not have breaking changes in future, they can determine whether to make it public.
425498

499+
426500
### FAQs
427501

428502
**When should an attribute be `required`?**

0 commit comments

Comments
 (0)