Skip to main content

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:

  1. Navigate to the desired API endpoint path:
    • modules/<module>/contracts/api/paths/...
  2. 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
]
}
}