firecamp-dev / firecamp

Developer-first OpenSource API DevTool, Postman/Insomnia alternative.
https://firecamp.dev
GNU Affero General Public License v3.0
2.1k stars 137 forks source link

feature: Implement request transformation between HAR and Firecamp formats #115

Closed Nishchit14 closed 1 year ago

Nishchit14 commented 1 year ago

Description:

Firecamp currently does not have the ability to transform HTTP request/response data between the HAR (HTTP Archive) format and Firecamp's internal request format.

This feature request is to implement bidirectional conversion:

This will allow:

The implementation should include:

This feature will enable better interoperability with external tools for importing and exporting HTTP request data.

Resources

  1. Firecamp Request Type: https://github.com/firecamp-dev/firecamp/blob/main/packages/firecamp-types/src/requests/rest/request.ts#L17C25-L17C25
  2. https://www.npmjs.com/package/@types/har-format
RISHIKESHk07 commented 1 year ago

Hey @Nishchit14 would like to contribute , though I have not much knowledge about the above issue.

Nishchit14 commented 1 year ago

The business logic of this feature is around HAR and Firecamp API Request transformation. Firecamp Rest Request and HAR both have JSON format. We need to create two transformer functions

Converts formats

  1. HAR Request to Firecamp Rest Request
  2. Firecamp Rest Request to HAR Request

Getting started steps would be

  1. create a new package under the packages/*, folder name firecamp-har and package name in package.json with @firecamp/firecamp-har, you can copy the existing package to start with typescript boilerplate
  2. start building transformer business logic
  3. write jest tests
  4. submit PR.

for any kind of help feel free to ask on Discord's contribution channel.

Reference

HAR JSON: https://gist.github.com/igrigorik/3495174 https://github.com/javieraviles/Har2Postman/blob/master/test/0.1.0/input.json TS: https://www.npmjs.com/package/@types/har-format

Firecamp JOSN: https://github.com/firecamp-dev/firecamp/blob/d43e50d017d381cfb05ac5408a90d23c935fafc5/packages/firecamp-cli/test/data/restEchoServer.firecamp_collection.json#L124-L190 TS: https://github.com/firecamp-dev/firecamp/blob/main/packages/firecamp-types/src/requests/rest/request.ts#L17C25-L17C25

@note: only transform request to request, do not consider whole collection transformation as of now.

cc: @RISHIKESHk07

jatingodnani commented 1 year ago

@Nishchit14 are you asking to implement a toll to convert a har to fire format and vice verse?

Nishchit14 commented 1 year ago

@jatingodnani yes, format conversion from HAR to Firecamp and Firecamp to HAR.

jatingodnani commented 1 year ago

@Nishchit14 where to implement this

Nishchit14 commented 1 year ago

@jatingodnani please read this https://github.com/firecamp-dev/firecamp/issues/115#issuecomment-1767796283, specific this section Getting started steps would be

jatingodnani commented 1 year ago

Screenshot 2023-10-19 121918 @Nishchit14 can you pls tell me is this correct?or i am missing something

jatingodnani commented 1 year ago

@Nishchit14 check this above

Nishchit14 commented 1 year ago

@jatingodnani Refer this https://github.com/firecamp-dev/firecamp/pull/120#issuecomment-1770504239

I appreciate your efforts to understand this issue. I need some time to prepare a minimum package so you can start. also the HAR <=> Firecamp comparison looks good at first sight but I prefer to have json in PR so I can review it properly.

jatingodnani commented 1 year ago

@Nishchit14 can you pls checkk and review is it correct conversion

Nishchit14 commented 1 year ago

@jatingodnani yes, it looks correct.

jatingodnani commented 1 year ago

@Nishchit14 i am ready to take this issue.