Initial push of codegen for Mikrotik RouterOS - routeros-fetch#770
Open
mobileskyfi wants to merge 39 commits intopostmanlabs:developfrom
Open
Initial push of codegen for Mikrotik RouterOS - routeros-fetch#770mobileskyfi wants to merge 39 commits intopostmanlabs:developfrom
routeros-fetch#770mobileskyfi wants to merge 39 commits intopostmanlabs:developfrom
Conversation
including newman (requires setup) and unit tests.
Author
|
Any update here? |
…improve first convert speed; added known issues to page
…erator for multiple headers)
potential difference in nodejs version?
The curl2rsc tool moved to the main tikoci.github.io site as a proper browser-side SPA. Redirect the old postman-code-generators Pages URL to the new location, forwarding any ?cmd=... and ?style=... query params. - meta refresh + JS replace() for instant redirect - canonical URL points to new location (SEO) - README tip updated to reference new URL Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Postman code generator for MikroTik RouterOS /tool/fetch (“routeros-fetch”), including unit tests and language labeling, plus additional repo-level website/CI workflow changes.
Changes:
- Introduces
codegens/routeros-fetchwith conversion logic, options (style,commentary), and test suites/resources. - Registers RouterOS in language labels.
- Adds GitHub Pages-related content (
index.html,static.yml) and modifies CI workflow triggers.
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| test/codegen/structure.test.js | Updates structure expectations/validations for codegen option IDs and .eslintrc presence. |
| package.json | Bumps root package version. |
| lib/assets/languageLabels.json | Adds routeros label mapping. |
| index.html | Adds a static page (redirect + UI) for curl-to-RouterOS conversion. |
| codegens/routeros-fetch/package.json | Defines new codegen package metadata. |
| codegens/routeros-fetch/index.js | Exposes the codegen module entrypoint. |
| codegens/routeros-fetch/lib/index.js | Implements RouterOS /tool/fetch snippet generation and options. |
| codegens/routeros-fetch/lib/utils.js | Adds RouterOS escaping/body/header utilities. |
| codegens/routeros-fetch/lib/lodash.js | Provides local lodash helpers (copied pattern). |
| codegens/routeros-fetch/.eslintrc | Adds ESLint configuration for the new codegen. |
| codegens/routeros-fetch/.gitignore | Adds ignore rules for the new codegen. |
| codegens/routeros-fetch/.npmignore | Adds npm ignore rules for the new codegen. |
| codegens/routeros-fetch/npm/test.js | Adds codegen test runner (lint + unit). |
| codegens/routeros-fetch/npm/test-lint.js | Adds ESLint runner script. |
| codegens/routeros-fetch/npm/test-unit.js | Adds Mocha+NYC unit test runner script. |
| codegens/routeros-fetch/npm/test-newman.js | Adds Mocha+NYC newman test runner script. |
| codegens/routeros-fetch/npm-shrinkwrap.json | Adds shrinkwrap for the new codegen package. |
| codegens/routeros-fetch/README.md | Documents the new codegen (currently boilerplate). |
| codegens/routeros-fetch/routeros-fetch-cmd | Adds a RouterOS snippet file (likely for newman usage). |
| codegens/routeros-fetch/test/unit/package.test.js | Adds package metadata validation tests. |
| codegens/routeros-fetch/test/unit/converter.test.js | Adds conversion behavior unit tests. |
| codegens/routeros-fetch/test/resources/test-collection.json | Adds fixture collection for unit tests. |
| codegens/routeros-fetch/test/resources/expected-http-messages.json | Adds expected output fixtures for unit tests. |
| codegens/routeros-fetch/test/resources/error-collection.json | Adds error-case fixtures for unit tests. |
| codegens/routeros-fetch/test/newman/newman.test.js | Adds newman-based integration tests scaffold. |
| codegens/routeros-fetch/test/newman/fixtures/basicCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/rawBody.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/formdataCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/emptyFormdataCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/formdataFileCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/queryParamsCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/redirectCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/sameNameHeadersCollection.json | Adds newman fixtures for routeros-fetch. |
| codegens/routeros-fetch/test/newman/fixtures/unsupportedMethods.json | Adds newman fixtures for routeros-fetch. |
| README.md | Adds fork/site references at repo root. |
| .github/workflows/test.yml | Modifies CI workflow triggers. |
| .github/workflows/static.yml | Adds a GitHub Pages deployment workflow. |
Files not reviewed (1)
- codegens/routeros-fetch/npm-shrinkwrap.json: Language not supported
Comments suppressed due to low confidence (1)
test/codegen/structure.test.js:282
- Enabling the
.eslintrcexistence check for every codegen will fail for many existing codegens that don't ship an.eslintrc(e.g.codegens/curl). Please revert this back todescribe.skip(...), or gate the check so it only applies to codegens that are expected to have an.eslintrc.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+7
to
+18
| ## Using the Module | ||
| The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to swift code snippet. | ||
|
|
||
| ### convert function | ||
| Convert function takes three parameters | ||
|
|
||
| * `request` - Postman-SDK Request Object | ||
|
|
||
| * `options` - options is an object which hsa following properties | ||
| * `indentType` - String denoting type of indentation for code snippet. eg: 'Space', 'Tab' | ||
| * `indentCount` - The number of indentation characters to add per code level | ||
| * `trimRequestBody` - Whether or not request body fields should be trimmed |
Comment on lines
+2
to
+12
| > [!TIP] | ||
| > ### For `curl` to `/tool/fetch` conversion, see this repo's webpage: | ||
| > #### https://tikoci.github.io/curl2rsc.html | ||
| > Source code lives at: https://github.com/tikoci/postman-code-generators/blob/develop/index.html | ||
|
|
||
| > [!IMPORTANT] | ||
| > ### Fork of `postman-code-generators` | ||
| > #### Supporting Mikrotik RouterOS `/tool/fetch` | ||
| > The Mikrotik RouterOS codegen is named `routeros-fetch` in Postman's _lang_-_library_ scheme. | ||
| > This forks code support RouterOS is largely within: https://github.com/tikoci/postman-code-generators/tree/develop/codegens/routeros-fetch | ||
|
|
Comment on lines
+104
to
+106
| #selectfetchoutput[value=""] { | ||
| display: node; | ||
| } |
| "author": "Postman Labs <help@getpostman.com>", | ||
| "license": "Apache-2.0", | ||
| "homepage": "https://github.com/postmanlabs/code-generators/tree/master/codegens/routeros-fetch", | ||
| "dependencies": {}, |
Comment on lines
1
to
4
| { | ||
| "name": "postman-code-generators", | ||
| "version": "1.13.0", | ||
| "version": "1.13.2", | ||
| "description": "Generates code snippets for a postman collection", |
Comment on lines
+7
to
+11
| * Used in order to get additional options for generation of C# code snippet (i.e. Include Boilerplate code) | ||
| * | ||
| * @module getOptions | ||
| * | ||
| * @returns {Array} Additional options specific to generation of http code snippet |
Comment on lines
+163
to
+170
| <div hx-post="https://curl2rsc.glitch.me/curl" hx-target="#tafetchcmd" hx-swap="innerHTML" hx-include="this" | ||
| hx-trigger="change"> | ||
| <fieldset id="curl2rscfields"> | ||
| <label> | ||
| <code>curl</code> | ||
| command line to convert from: | ||
| <input name="cmd" hx-post="https://curl2rsc.glitch.me/curl" hx-target="#tafetchcmd" | ||
| hx-swap="innerHTML" hx-trigger="keyup changed delay:2s" id="inputcurl" required |
Comment on lines
+39
to
+40
| # Upload entire repository | ||
| path: '.' |
Comment on lines
+85
to
+89
| const pasteClipboadText = (id) => { | ||
| navigator.clipboard.readText().then((clipText) => | ||
| document.getElementById(id).value = clipText).error((error) => { | ||
| console.error(error.message); | ||
| }) |
Comment on lines
+114
to
+121
| // var urlnoauth = Url.parse(request.url.toString(true)); | ||
| request.url.auth = null; | ||
| if (request.url.getHost().startsWith('http')) { | ||
| const invalidHost = new Url(request.url.getHost()); | ||
| request.url.host = invalidHost.getHost(); | ||
| request.url.protocol = invalidHost.protocol; | ||
| } | ||
| attrs.set('url', utils.escapeRouterOSString(request.url.toString(true))); |
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.
New codegen for Mikrotik's RouterOS /tool/fetch command, in Postman terms named
routeros-fetch. The command is used on any Mikrotik router to run web services. But RouterOS syntax is not the easiest since it requires specific escaping. So this "snippet" will deal with mapping a Postman Request, with the right string encoding. Error and tips are presented as RouterOS comments in the snippet. Two new options are addedcommentaryto control if errors/tips are shown &styleto control to specific form of the command as it can be used interactively or as a variable in a larger script.Code was created using "npm boilerplate", with code/structure borrowed from
httpcodegen since RouterOS requires similar "raw-like" bodies. Added "test-unit" that verify the RouterOS codegen offline, similar to the http file codegen unit tests.The Newman tests do run successfully, except they require MikroTik RouterOS device running with SSH enabled to test (see codegen/routeros-fetch. I ran these manually.
See Issue #769 - Codegen push for Mikrotik RouterOS's /tool/fetch CLI command (routeros-fetch)