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

Add REST Importer for Jetbrains / VSCode #435

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading