fix: correct firmware API base path and destructure parameter objects#3
Open
chr2sn0 wants to merge 1 commit into
Open
fix: correct firmware API base path and destructure parameter objects#3chr2sn0 wants to merge 1 commit into
chr2sn0 wants to merge 1 commit into
Conversation
…irmware The firmware controller in OPNsense lives under the 'core' module, making /api/core/firmware the correct base path. The generators were incorrectly deriving the path as /api/firmware (using the module name literally), which resulted in 404 errors on all firmware API calls. Changes: - generators/generate-core-modules.js: Map firmware module basePath to /api/core/firmware instead of /api/firmware - generators/generate-sdk.js: Apply same basePath mapping during SDK transformation, fix package.json export filenames to match Rollup output (.cjs/.js instead of .js/.esm.js) - typescript/core/firmware.ts: Add object-parameter overloads for methods with path parameters (pkgName, version, clear) to support single-object invocation from MCP tool dispatch - src/core/firmware.ts: Regenerated with correct paths and overloads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses two critical bugs when interacting with the OPNsense firmware API module:
1. Correct base path mapping for the Firmware module
coremodule path:/api/core/firmware. The generators mapped it to/api/firmware(using the subfolder name/typescript/core/firmware), which resulted in404 Not Founderrors for all firmware actions (install, update, query, etc.).generators/generate-core-modules.jsandgenerators/generate-sdk.jsto mapfirmwareto/api/core/firmware.2. Object parameter support (destructuring) for SDK methods
firmwareInstall({pkgName: "os-crowdsec"})), parameters were being serialized incorrectly as[object Object]in the URL path.typescript/core/firmware.tsto accept parameter objects and safely destructure variables (such aspkgName,version, andclear) into URL segments.Technical Details
generators/generate-core-modules.js:Maps
firmware'sbasePathto/api/core/firmware.generators/generate-sdk.js:Aligns regexes and transforms class constructor types dynamically to map paths correctly. Also corrects the Rollup bundle outputs in
package.jsonto matching.js/.cjsextensions.typescript/core/firmware.ts:Declares helper methods and object signatures for single-object parameters.
src/core/firmware.ts:Regenerated SDK module.