| name | add-query-param |
| description | This rule describes how to add a new QueryParam feild to a function. |
Adding Query Parameters
When adding a new query parameter to a function, follow these steps:
-
Identify the QueryParams Model
- Locate the
<Function>QueryParams class in the appropriate command directory
- This model should be in the same directory as the command implementation
-
Add the New Parameter
class FunctionQueryParams(BaseModel):
new_param: type = Field(
default=default_value,
description="Description of the parameter",
examples=["example_value"]
)
-
Data Model Impact Assessment
- Does this parameter affect the output data structure?
- If yes, update
<Function>Data model accordingly
- If no, proceed to step 4
-
Update Fetcher Logic
- Modify the fetcher class to handle the new parameter
- Update
transform_query() if needed
- Update
transform_data() if the parameter affects data processing
-
Documentation
- Update function docstring with new parameter
- Add parameter to examples in docstring
- Update any relevant API documentation
-
Testing
- Add test cases for the new parameter
- Test both default and custom values
- Verify data transformation with new parameter
Example:
class MandelbrotChannelQueryParams(BaseModel):
window: str
rv_adjustment: bool
class MandelbrotChannelQueryParams(BaseModel):
window: str
rv_adjustment: bool
new_param: bool = Field(
default=False,
description="New parameter description",
examples=[True, False]
)
Remember:
- Always use Pydantic's
Field for parameter definitions
- Provide clear descriptions and examples
- Consider backward compatibility
- Update tests and documentation