Skip to content

Initial push of codegen for Mikrotik RouterOS - routeros-fetch#770

Open
mobileskyfi wants to merge 39 commits intopostmanlabs:developfrom
tikoci:develop
Open

Initial push of codegen for Mikrotik RouterOS - routeros-fetch#770
mobileskyfi wants to merge 39 commits intopostmanlabs:developfrom
tikoci:develop

Conversation

@mobileskyfi
Copy link
Copy Markdown

@mobileskyfi mobileskyfi commented Sep 23, 2024

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 added commentary to control if errors/tips are shown & style to 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 http codegen 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)

@mobileskyfi
Copy link
Copy Markdown
Author

Any update here?

SkyFi Geek and others added 10 commits November 8, 2024 09:17
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>
Copilot AI review requested due to automatic review settings April 14, 2026 19:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-fetch with 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 .eslintrc existence check for every codegen will fail for many existing codegens that don't ship an .eslintrc (e.g. codegens/curl). Please revert this back to describe.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 thread README.md
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 thread index.html
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 thread package.json
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 thread index.html
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 thread index.html
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)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants