Skip to content

Commit

Permalink
Add REST format importer (for JetBrains/VSCode)
Browse files Browse the repository at this point in the history
  • Loading branch information
benfaerber authored and LucasPickering committed Jan 1, 2025
1 parent 5c85a1f commit 5b96fb5
Show file tree
Hide file tree
Showing 10 changed files with 790 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased] - ReleaseDate

### Added

- Add REST Importer for VSCode and Jetbrains

### Changed

- Update [editor-command](https://crates.io/crates/editor-command), which replaces [shellish_parse](https://crates.io/crates/shellish_parse) with [shell-words](https://crates.io/crates/shell-words) for editor and pager command parsing
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion crates/cli/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use std::{
};

/// Generate a Slumber request collection from an external format
///
/// See docs for more info on formats:
/// https://slumber.lucaspickering.me/book/cli/import.html
#[derive(Clone, Debug, Parser)]
pub struct ImportCommand {
/// Input format
Expand All @@ -25,8 +28,12 @@ enum Format {
/// Insomnia export format (JSON or YAML)
Insomnia,
/// OpenAPI v3.0 (JSON or YAML) v3.1 not supported but may work
/// https://spec.openapis.org/oas/v3.0.3
Openapi,
/// VSCode `.rest` or JetBrains `.http` format [aliases: vscode, jetbrains]
// Use visible_alias (and remove from doc comment) after
// https://github.com/clap-rs/clap/pull/5480
#[value(alias = "vscode", alias = "jetbrains")]
Rest,
}

impl Subcommand for ImportCommand {
Expand All @@ -37,6 +44,7 @@ impl Subcommand for ImportCommand {
slumber_import::from_insomnia(&self.input_file)?
}
Format::Openapi => slumber_import::from_openapi(&self.input_file)?,
Format::Rest => slumber_import::from_rest(&self.input_file)?,
};

// Write the output
Expand Down
1 change: 1 addition & 0 deletions crates/import/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ indexmap = {workspace = true, features = ["serde"]}
itertools = {workspace = true}
mime = {workspace = true}
openapiv3 = "2.0.0"
rest_parser = "0.1.6"
reqwest = {workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
Expand Down
2 changes: 2 additions & 0 deletions crates/import/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod insomnia;
mod openapi;
mod rest;

pub use insomnia::from_insomnia;
pub use openapi::from_openapi;
pub use rest::from_rest;
Loading

0 comments on commit 5b96fb5

Please sign in to comment.