Skip to content

Commit ac4f4b7

Browse files
formatting
1 parent f53b43c commit ac4f4b7

File tree

1 file changed

+71
-16
lines changed

1 file changed

+71
-16
lines changed

develop-docs/backend/api/public.mdx

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,77 @@ 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+
**Problem**: `TypeError: Cannot read properties of null (reading 'type')`
416+
417+
**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.
418+
419+
---
420+
421+
**Problem**: `must have required property '<property_name>'`
422+
```json
423+
{
424+
"type": "Validation",
425+
"message": "must have required property '<property_name>'",
426+
"instancePath": "",
427+
"schemaPath": "#/required",
428+
"keyword": "required",
429+
"params": {
430+
"missingProperty": "<property_name>"
431+
},
432+
"examplePath": "<endpoint_path>"
433+
}
434+
```
435+
436+
**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.
437+
438+
---
439+
440+
**Problem**: `must NOT have additional properties`
441+
```json
442+
{
443+
"type": "Validation",
444+
"message": "must NOT have additional properties",
445+
"instancePath": "",
446+
"schemaPath": "#/additionalProperties",
447+
"keyword": "additionalProperties",
448+
"params": {
449+
"additionalProperty": "<property_name>"
450+
},
451+
"examplePath": "<endpoint_path>"
452+
}
453+
```
454+
455+
**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.
456+
457+
---
458+
459+
**Problem**: `must be <type>`
460+
```json
461+
{
462+
"type": "Validation",
463+
"message": "must be <type>",
464+
"instancePath": "/0/<property_name>",
465+
"schemaPath": "#/items/properties/<property_name>/type",
466+
"keyword": "type",
467+
"params": {
468+
"type": "<type>"
469+
},
470+
"examplePath": "<endpoint_path>"
471+
}
472+
```
473+
474+
**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.
475+
476+
---
477+
478+
**Problem**: `sentry.apidocs.utils.SentryApiBuildError: projects is not defined by OPENAPI_TAGS in src/sentry/apidocs/build.py for <endpoint title>`
479+
480+
**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>'])`.
481+
482+
---
483+
413484
## Requesting an API to be public
414485

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

426-
### Test Troubleshooting
427-
*Problem*: `TypeError: Cannot read properties of null (reading 'type')`
428-
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.
429-
430-
*Problem*: `must have required property '<property>'`
431-
Your example response is missing one of the required properties specified by the response class. The property should either be made optional or you should add it to the example.
432-
433-
*Problem*: `must NOT have additional properties`
434-
Your example response includes a property not included in the response class. This either needs to be added to the response class or removed from the example. s
435-
436-
*Problem*: `must be <type>`
437-
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.
438-
439-
*Problem*: `sentry.apidocs.utils.SentryApiBuildError: projects is not defined by OPENAPI_TAGS in src/sentry/apidocs/build.py for <endpoint title>`
440-
You need to add the endpoint to a section of the API docs with the `@extend_schema(tags=['<section title>'])`. Section tags live at [`src/sentry/apidocs/build.py`](https://github.com/getsentry/sentry/blob/isabella/proj-env-details/src/sentry/apidocs/build.py).
441-
442497

443498
### FAQs
444499

0 commit comments

Comments
 (0)