|
| 1 | +--- |
| 2 | +title: "Managing page visibility" |
| 3 | +description: "Control which endpoints from your OpenAPI specification appear in your documentation navigation" |
| 4 | +--- |
| 5 | + |
| 6 | + |
| 7 | +You can control exactly which parts of your OpenAPI specification get published and how they're organized. Hiding pages can be useful when you're documenting internal APIs, beta features, or other endpoints that shouldn't appear in navigation. |
| 8 | + |
| 9 | +If your pages are autogenerated from an OpenAPI document, you can control which endpoints get published and how they appear in your documentation with the `x-hidden` and `x-excluded` properties. |
| 10 | + |
| 11 | +## `x-hidden` |
| 12 | + |
| 13 | +The `x-hidden` property creates a page for an endpoint, but hides it from navigation. The page is only accessible by navigating directly its URL. |
| 14 | + |
| 15 | +Common use cases for `x-hidden` are: |
| 16 | + |
| 17 | +- Endpoints you want to document, but not promote. |
| 18 | +- Pages that you will link to from other content. |
| 19 | +- Endpoints for specific users. |
| 20 | + |
| 21 | +## `x-excluded` |
| 22 | + |
| 23 | + |
| 24 | +The `x-excluded` property completely excludes an endpoint from your documentation. |
| 25 | + |
| 26 | +Common use cases for `x-excluded` are: |
| 27 | + |
| 28 | +- Internal-only endpoints. |
| 29 | +- Deprecated endpoints that you don't want to document. |
| 30 | +- Beta features that are not ready for public documentation. |
| 31 | + |
| 32 | +## Implementation |
| 33 | + |
| 34 | +Add the `x-hidden` or `x-excluded` property under the HTTP method in your OpenAPI specification. |
| 35 | + |
| 36 | +Here are examples of how to use each property in an OpenAPI schema document for an endpoint and a webhook path: |
| 37 | + |
| 38 | +```json {11, 19} |
| 39 | +"paths": { |
| 40 | + "/plants": { |
| 41 | + "get": { |
| 42 | + "description": "Returns all plants from the store", |
| 43 | + "parameters": { ... }, |
| 44 | + "responses": { ... } |
| 45 | + } |
| 46 | + }, |
| 47 | + "/hidden_plants": { |
| 48 | + "get": { |
| 49 | + "x-hidden": true, |
| 50 | + "description": "Returns all somewhat secret plants from the store", |
| 51 | + "parameters": { ... }, |
| 52 | + "responses": { ... } |
| 53 | + } |
| 54 | + }, |
| 55 | + "/secret_plants": { |
| 56 | + "get": { |
| 57 | + "x-excluded": true, |
| 58 | + "description": "Returns all top secret plants from the store (do not publish this endpoint!)", |
| 59 | + "parameters": { ... }, |
| 60 | + "responses": { ... } |
| 61 | + } |
| 62 | + } |
| 63 | +}, |
| 64 | +``` |
| 65 | + |
| 66 | +```json {9, 15} |
| 67 | +"webhooks": { |
| 68 | + "/plants_hook": { |
| 69 | + "post": { |
| 70 | + "description": "Webhook for information about a new plant added to the store", |
| 71 | + } |
| 72 | + }, |
| 73 | + "/hidden_plants_hook": { |
| 74 | + "post": { |
| 75 | + "x-hidden": true, |
| 76 | + "description": "Webhook for somewhat secret information about a new plant added to the store" |
| 77 | + } |
| 78 | + }, |
| 79 | + "/secret_plants_hook": { |
| 80 | + "post": { |
| 81 | + "x-excluded": true, |
| 82 | + "description": "Webhook for top secret information about a new plant added to the store (do not publish this endpoint!)" |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
0 commit comments