Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Restfox DSL #145

Open
eznix86 opened this issue May 12, 2024 · 5 comments
Open

Create Restfox DSL #145

eznix86 opened this issue May 12, 2024 · 5 comments

Comments

@eznix86
Copy link
Contributor

eznix86 commented May 12, 2024

Instead of exporting data in JSON, which is quite verbose, we can introduce a RestFox DSL. Similar to .bru.

We can have a hydrator in between from current JSON implementation to the DSL. Making easy to convert the JSON into a DSL and DSL back to JSON for import so it does not change anything.

Advantages of having a DSL instead of passing a JSON around.

Example: https://github.com/usebruno/bruno/blob/main/packages/bruno-lang/v2/src/collectionBruToJson.js

References: https://docs.usebruno.com/bru-lang/tag-reference

meta {
  name: Login User
  type: http
  seq: 1
  docs: Login to the service
}

post {
  url: https://api.myservice.com/login
}

headers {
  content-type: application/json
  x-staging-wall: topsecret-key
}
 
body {
  {
    "username": "johnnash",
    "password": "governingdynamics"
  }
}
 
script:post-request {
   let response = rf.response.getBodyJSON()
   rf.setEnvVar('ACCESS_TOKEN', response.data.access_token)
}
meta {
  name: Login User
  type: socket
  seq: 1
  docs: Live tweets
}

ws {
  url: wss://twitter.com/live/tweets
}

payloads {
 {
    ...
  }
}
 

Questions to reflect upon:

  • Is it necessary for that project?
  • Why not just support .bru files directly instead of creating a restfox version?

My personal reflection on these:

  • Not necessary but it is great to just have a folder with everything which can be version controlled and edited.
  • .bru might not go the same direction as restfox, it tries act as a file browser with rest client on top. Here we are just translating that big blob of JSON into a readable format which can be edited easily, imported/exported easily
@eznix86 eznix86 changed the title Restfox DSL Create Restfox DSL May 12, 2024
@flawiddsouza
Copy link
Owner

Heyo, just to put this out of the way, Restfox already has a file workspaces feature as of https://github.com/flawiddsouza/Restfox/releases/tag/v0.7.0. It allows you to have each request and folder as a file and a folder in your file system. So that you can have put it all in a git repo.

Workspaces are broken down into real folders (usebruno/github-rest-api-collection@main/Repository/Search%20Repos.bru)

Is it necessary for that project? Not necessary but it is great to just have a folder with everything which can be version controlled and edited.

So this feature you mention is already present.

But the point of a DSL might still be valid. But it is a lot of work. I have thought of supporting .bru directly. I'm undecided. This issue can serve as the basis for the spec for the DSL.

@eznix86
Copy link
Contributor Author

eznix86 commented May 12, 2024

Oh thanks for pointing out ! I will try out this feature!

I believe supporting .bru is quite q challenge especially if the specifications keeps changing because they are new.

@sakirtemel
Copy link

supporting bru files can be quite a good thing! let me explain why it can be helpful for our development flow for example:

I have services in different repositories and each of them have docs/api_collection folder that has the bru files in it.

  1. I develop a feature in a PR, adding / modifying the bru files
  2. I'm able to do npm run . --test-only on the CI to validate the queries are still working.
  3. After I merge, a github action is copying the bru files to a central repository, so that the aggregated version of the API collection can be available for use
  4. I need to pull the changes time to time to update my collection and use the Desktop app for sending some requests to our environment

with Restfox however, what we can achieve:

after nr3, I can host an internal restfox that is based on the aggregated collection instead of the Desktop app.

also if possible, after nr1, I could do restfox docs/api_collection that opens a browser for the given repository, just not sure modification of the files will also be effecting the bru files directly.

@eznix86
Copy link
Contributor Author

eznix86 commented May 21, 2024

interesting point of view, so I believe support for .bru is much more interesting than making a restfox version.

@flawiddsouza
Copy link
Owner

I've always wanted to have bru support in Restfox, so this works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants