How do I configure parameters on an API endpoint?
Objective: This article explains how to configure parameters (query strings or path) on an API endpoint.
Steps:
- Navigate to the desired API endpoint path:
modules/<module>/contracts/api/paths/...
- Amend the
parameters
array.
Example:
// Path parameters
import { CommonOpenApi as schema } from '@hectare/platform.components.common'
...
'/path/to/endpoint/{id}': { // <-- Path parameter
get: {
...
parameters: [
schema.parameters.id() // <-- Related parameter configuration
]
}
}
// Query parameters
import { CommonOpenApi as schema } from '@hectare/platform.components.common'
...
'/path/to/endpoint': {
get: {
...
parameters: [
schema.query.latitude, // <-- Query parameters
schema.query.longitude
]
}
}