Skip to content

v1.2.0

Choose a tag to compare

@yhnavein yhnavein released this 09 Aug 22:20
· 45 commits to master since this release
e15c64c
  • feat: Added global parameter modifiers. More explanation below
  • impr: Introduced skippable parameters - if optional parameters is not followed by required one, it will be rendered as p1?: string | null so it's possible to skip such parameters when calling operation
  • refactor: Replaced mocha + chai with node test runner + tsx
  • chore: upgrade deps
  • fix: matrix testing of node versions in Github Actions is now fixed

Parameter modifiers

This feature addresses scenarios where OpenAPI specifications contain globally-defined parameters that are already handled by application interceptors, eliminating redundant parameter definitions.

When working with REST APIs that define interceptors for common functionality (such as authentication), the OpenAPI specification may explicitly include these parameters across all operations. While Swaggie correctly interprets these as required parameters, your application's interceptor may already provide this information automatically, making manual parameter specification redundant.

Parameter modifiers can be configured through the config.json file using the following structure:

{
  "modifiers": {
    "parameters": {
      "param1": "optional",
      "param2": "ignore"
    }
  }
}

Available Modifiers:

ignore - Removes the parameter from all operations and paths entirely (most common use case)
optional - Makes a parameter optional while preserving interceptor functionality
required - Forces a parameter to be marked as required, useful when the OpenAPI spec doesn't properly define a parameter's necessity

Note: When using the optional modifier, the interceptor's default value takes precedence in the outgoing request. Ensure your interceptor logic can handle cases where the parameter might be explicitly provided.

For the parameter's name you want to to modify you can provide either the original name from the spec, or the name as visible in the generated code.