Configuration
The Starlight OpenAPI plugin can be configured inside the astro.config.mjs
configuration file of your project:
You can also add custom styles to the generated documentation by adding a styles/custom.css
file in the same directory as the astro.config.mjs
file and adding the following CSS:
Plugin configuration
The Starlight OpenAPI plugin accepts an array of objects where each object represents a configuration for a specific OpenAPI/Swagger schema.
A configuration object can have the following properties:
base
(required)
Type: string
The base path containing the generated documentation, e.g. 'api/petstore'
.
schema
(required)
Type: string
The OpenAPI/Swagger schema path or URL.
label
Type: string
The generated documentation sidebar group label.
collapsed
Type: boolean
Wheter the generated documentation sidebar group should be collapsed by default or not.
rapidocAttrs
Type: object
// Record<String, any>
Additional attributes to pass to the Rapidoc component. Can you be used to customize the generated documentation.
Details about the available attributes can be found in the Rapidoc documentation.
The default value is:
showMethodBadgeSidebar
Type: boolean
Whether to show the method badge in the sidebar or not.
Additional styles can be added in styles/custom.css
file in the same directory as the astro.config.mjs
file and adding the following CSS:
Multiple schemas
You can generate documentation for multiple OpenAPI/Swagger schemas by passing multiple objects to the plugin configuration.
Sidebar groups
The openAPISidebarGroups
export can be used in your Starlight sidebar configuration to add the generated documentation sidebar group to the sidebar.