Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in

Overview

Restish Logo

Works With Restish User Guide CI codecov Docs Go Report Card

Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in, like always having the latest API resources, fields, and operations available when they go live on the API without needing to install or update anything.

See the user guide to get started.

Features include:

This project started life as a fork of OpenAPI CLI Generator.

Comments
  • inconsistent usage of flags

    inconsistent usage of flags

    Running restish against https://petstore3.swagger.io/api/v3/openapi.json gives me the following endpoint usage message:

    Usage:
      restish petstore find-pets-by-status [flags]
    
    Aliases:
      find-pets-by-status, findpetsbystatus
    
    Flags:
      -h, --help            help for find-pets-by-status
          --status string   Status values that need to be considered for filter (default "available")
    
    

    Running restish petstore findpetsbystatus --status available yields

    HTTP/2.0 400 Bad Request
    

    while restish petstore findpetsbystatus -q status=available yields the expected response.

    So the flag --status seems not to work as expected as described in the usage message.

    But it works with restish petstore findpetsbytags --tags animal although it has a similar usage:

    Usage:
      restish petstore findpetsbytags [flags]
    
    Flags:
      -h, --help           help for findpetsbytags
          --tags strings   Tags to filter by
    
    bug 
    opened by myrho 8
  • How to use a Self Signed CA Cert with an API

    How to use a Self Signed CA Cert with an API

    Is there a way to use a Self Signed CA Cert (Corporate CA) with a specific API without having to add it to the System CA Cert location? We do not necessarily have root access on our deployment agents in which to load the CA Cert ..

    question 
    opened by jonathan-kaufman-by 7
  • "Unexpected Escape Sequence" when using menu with arrow keys

    While using the api configure menus, the arrow keys cause an error. I can select menu options buy starting to type the text for the option.

    % restish api configure example
    ? Base URI http://example.org
    Setting up a `default` profile
    ? Select option for profile `default`  [Use arrows to move, type to filter]
    > Add header
      Add query param
      Setup auth
      Finished with profile
    ERROR: Caught error: Unexpected Escape Sequence: ['\x1b' 'O']
    

    I'm using the regular terminal emulator on MacOS with zsh

    help wanted 
    opened by platy 5
  • Usage as a library

    Usage as a library

    I have a project and its corresponding OpenAPI spec and I'm in the process of making a CLI for it. I had very similar ideas as restish and I'm so glad all the hard work has already been done! Thanks for that!

    For the CLI, I want to "embed" the ability to control the project as a subcommand as I would like to have more things in the CLI which aren't talking to the API. Would such a thing be possible here? Mainly im interesed in picking up the parsing of the openapi yaml and maybe getting back a list of cobra.Commands or something so that I can add it to my CLI as a subcommand.

    Would such a feature be useful? If yes, I'm happy to contribute it too! 😄

    Thanks again for building this!

    question 
    opened by lispyclouds 4
  • Comparison with curl and httpie

    Comparison with curl and httpie

    It would be helpful for prospective adopters to see a direct comparison of features (or main stand-out differences) between restish and alternative tools like curl and httpie.

    For example, a comparison table like the ones shown by delta or zola, or even a hello world comparison like what's done in the Chain.jl README, would be very helpful to encourage people to explore this tool further.

    documentation enhancement 
    opened by waldyrious 4
  • openapi: avoid adding non required parameters with no default value

    openapi: avoid adding non required parameters with no default value

    Hey,

    I have an openapi endpoint with some non required query parameters with no default value set in spec.

    Restish sets these implicitly. I suggest avoiding this as it puts empty values which may not always work well.

    Thanks.

    bug help wanted 
    opened by asaf 4
  • Version 0.11.0 stop working

    Version 0.11.0 stop working

    I upgraded to 0.11.0 version and now I get this error every time I want to run restish command

    ERROR: Caught error: yaml: unmarshal errors: line 1: cannot unmarshal !!seq into map[string]interface {}

    bug question 
    opened by 0fefe 3
  • got error while file is correct in swagger and redocly

    got error while file is correct in swagger and redocly

    goroutine 1 [running]: github.com/danielgtaylor/restish/cli.Run() /home/runner/work/restish/restish/cli/cli.go:496 +0x94c main.main() /home/runner/work/restish/restish/main.go:27 +0x238

    How I can verify openapi file with restish and get more information?

    help wanted question needs-repro 
    opened by iShift 3
  • Not using OpenAPI v2 json spec

    Not using OpenAPI v2 json spec

    My api is using a json openapi v2 spec hosted at /openapi.json. When I configure it there is no error and I see in the server logs that both /openapi.yaml and /openapi.json are requested. But when I try restish example --help or anything else I get the below error and in the server log I see that only the yaml is requested.

    % restish example --help
    panic: could not detect API type: http://localhost:8080/
    
    goroutine 1 [running]:
    github.com/danielgtaylor/restish/cli.Run()
    	/home/runner/work/restish/restish/cli/cli.go:447 +0x777
    main.main()
    	/home/runner/work/restish/restish/main.go:27 +0x177
    

    I installed using homebrew.

    question 
    opened by platy 3
  • Allow relative path server URLs

    Allow relative path server URLs

    We are using swagger to comply with the OpenAPI 3.0 spec and currently have outlined a single server:

    servers:
      - url: /v1
        name: API Version 1
    

    We use this configuration to enable us to set the paths on each endpoint to be version-agnostic, and the swagger interface (according to the openapi spec) will use the relative path /v1 as a prefix for each of our defined paths against the current hostname being accessed.

    We are hoping to gain the same functionality out of the restish configuration. When we go to add an api to restish, we are explicitly indicating the protocol/hostname of the API we are trying to access. Even though we do have the /v1 server setup, the following code indicates that it will be ignored since it is not prefixed with an absolute ${scheme}://${host}, which results in all of our paths being requested against the root of our api server instead of the path /v1.

    	// See if this server has any base path prefix we need to account for.
    	// TODO: handle variables in the server path?
    	basePath := ""
    	prefix := location.Scheme + "://" + location.Host
    	for _, s := range swagger.Servers {
    		if strings.HasPrefix(s.URL, prefix) {
    			base, err := url.Parse(s.URL)
    			if err != nil {
    				return cli.API{}, err
    			}
    			basePath = base.Path
    		}
    	}
    

    Proposed Change:

    Modify the above code to respect relative server URLs. If the serverUrl is an absolute path, continue with the HasPrefix check, if not, set the basePath to the relative route /v1.

    Thanks for your help, this should be a quick fix and will help get us up and running!

    opened by mgagliardo91 3
  • Authorization Code flow wrong cache key

    Authorization Code flow wrong cache key

    The authorization code workflow caches the authorization url as authorization_url; however, its usage in the remainder of the flow is for the name AuthorizeUrl (authorize_url). This results in an invalid authorization code URL being presented to the console.

    Cached usage: https://github.com/danielgtaylor/restish/blob/master/oauth/authcode.go#L157

    func (h *AuthorizationCodeHandler) Parameters() []cli.AuthParam {
    	return []cli.AuthParam{
    		{Name: "client_id", Required: true, Help: "OAuth 2.0 Client ID"},
    		{Name: "authorization_url", Required: true, Help: "OAuth 2.0 authorization URL, e.g. https://api.example.com/oauth/authorize"},
    		{Name: "token_url", Required: true, Help: "OAuth 2.0 token URL, e.g. https://api.example.com/oauth/token"},
    		{Name: "scopes", Help: "Optional scopes to request in the token"},
    	}
    }
    

    Proposed Change:

    func (h *AuthorizationCodeHandler) Parameters() []cli.AuthParam {
    	return []cli.AuthParam{
    		{Name: "client_id", Required: true, Help: "OAuth 2.0 Client ID"},
    		{Name: "authorize_url", Required: true, Help: "OAuth 2.0 authorization URL, e.g. https://api.example.com/oauth/authorize"},
    		{Name: "token_url", Required: true, Help: "OAuth 2.0 token URL, e.g. https://api.example.com/oauth/token"},
    		{Name: "scopes", Help: "Optional scopes to request in the token"},
    	}
    }
    
    opened by mgagliardo91 3
  • Add TLS Config before Auth

    Add TLS Config before Auth

    Hello,

    I'm trying to use Restish with a corporate API that requires OAuth 2.0 Client Credentials authentication. The authentication /token endpoint also requires a client certificate. With the current version of Restish, I've the following error message:

    ERROR: Caught error: oauth2: cannot fetch token: 400 Bad Request
    Response: <html>
    <head><title>400 No required SSL certificate was sent</title></head>
    ...
    </html>
    

    With this proposed patch, it is working fine. Can you please have a look and tell me if it can be merged?

    Thanks and Regards

    bug 
    opened by MartyHub 0
  • When multiple APIs are configured, and one's base path is a more specific prefix of the other, restish picks the api to use at random.

    When multiple APIs are configured, and one's base path is a more specific prefix of the other, restish picks the api to use at random.

    Dirty example of apis.json:

    "api1": {
          "base": "https://api.example.com",
    ...
    "api2": {
         "base": "https://api.example.com/foo"
    }
    

    If restish is configured like the above, it will randomly switch between api1 and api2 when executing commands: i.e.

    restish api1 command1
    

    will sometimes execute against api2 instead of api1.

    bug 
    opened by jwong-isp 0
  • Commands from operationId

    Commands from operationId

    Restish generates convenient command names such as "messaging-email-address-status-get".

    However, our OpenAPI spec defines operationId for all the operations. Is it possible to have Restish use those instead?

    question 
    opened by ServerlessArchitect 3
  • Literal commas with CLI shorthand

    Literal commas with CLI shorthand

    I can't seem to find a way to include literal commas when using the CLI Shorthand Syntax. For example:

     ~  restish post "https://httpbin.org/post" sender.id: test, "text: Hello, CLI"
    HTTP/2.0 200 OK
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Content-Length: 724
    Content-Type: application/json
    Date: Mon, 13 Jun 2022 18:30:07 GMT
    Server: gunicorn/19.9.0
    
    {
      args: {}
      data: "{\"sender\":{\"id\":\"test\"},\"text\":[\"Hello\",\"CLI\"]}"
      files: {}
      form: {}
      headers: {
        Accept: "application/cbor;q=0.9,application/msgpack;q=0.8,application/ion;q=0.6,application/json;q=0.5,application/yaml;q=0.5,text/*;q=0.2,*/*"
        Accept-Encoding: "gzip, br"
        Content-Length: "47"
        Content-Type: "application/json; charset=utf-8"
        Host: "httpbin.org"
        User-Agent: "restish-0.14.0"
        X-Amzn-Trace-Id: "Root=1-62a7822f-030b972753d9dc835d9eb580"
      }
      json: {
        sender: {
          id: "test"
        }
        text: ["Hello", "CLI"]
      }
      origin: "..."
      url: "https://httpbin.org/post"
    }
    

    It is unexpected to me that my "Hello, CLI" becomes an array. This is what I'm trying to accomplish:

    ...
        sender: {
          id: "test"
        }
        text: "Hello, CLI"
      }
    
    bug 
    opened by ServerlessArchitect 1
  • Reliably set the exist status code on errors

    Reliably set the exist status code on errors

    Currently there are cases where an error correctly sets a status code <> 0 (e.g. on authentication failures) but other cases (e.g. host not reachable, HTTP 400/500) exit with success, making it hard to use in scripts. I'd propose to always set an error code on hard errors (e.g. communication failures) and provide an option (similar to curl) to exit with an error status if the HTTP status code responds with an error (4xx/5xx).

    bug 
    opened by ahochsteger 0
  • Validate application/json schema

    Validate application/json schema

    Hi!

    I would like Restish to be able to validate my application/json schema so it can trigger at least an error when an unknown parameter is provided before making any API call.

    As an example: DryRun boolean or SomeObject object would be validated but not SomeObjet (which is a typo).

      /MyObject:
        post:
          operationId: CreateMyObject
          requestBody:
            content:
              application/json:
                schema:
                  $ref: '#/components/schemas/CreateMyObjectRequest'
    [...]
        CreateMyObjectRequest:
          additionalProperties: false
          properties:
            DryRun:
              type: boolean
            SomeObject:
              $ref: '#/components/schemas/SomeObject'
          type: object
    [...]
    

    What do you think of this feature?

    enhancement 
    opened by jerome-jutteau 0
Releases(v0.14.0)
Owner
Daniel G. Taylor
Daniel G. Taylor
Go net/http configurable handler to handle CORS requests

Go CORS handler CORS is a net/http handler implementing Cross Origin Resource Sharing W3 specification in Golang. Getting Started After installing Go

Olivier Poitrey 2.2k Oct 1, 2022
Go net/http handler to transparently manage posted JSON

Go JSON handler FormJSON is a net/http handler implementing content negotiation for posted data in order to transparently expose posted JSON as if it

Olivier Poitrey 38 Sep 27, 2022
Fault injection library in Go using standard http middleware

Fault The fault package provides go http middleware that makes it easy to inject faults into your service. Use the fault package to reject incoming re

GitHub 464 Sep 27, 2022
Go (golang) library for creating and consuming HTTP Server-Timing headers

HTTP Server-Timing for Go This is a library including middleware for using HTTP Server-Timing with Go. This header allows a server to send timing info

Mitchell Hashimoto 841 Sep 27, 2022
Simple middleware to rate-limit HTTP requests.

Tollbooth This is a generic middleware to rate-limit HTTP requests. NOTE 1: This library is considered finished. NOTE 2: Major version changes are bac

Didip Kerabat 2.3k Sep 27, 2022
哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP、TCP、Ping 监控报警,命令批量执行和计划任务

哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP、TCP、Ping 监控报警,命令批量执行和计划任务

null 3.3k Sep 25, 2022
A SimpleHTTPServer written in Go, enhanced with features and with a nice design

goshs is a replacement for Python's SimpleHTTPServer. It allows uploading and downloading via HTTP/S with either self-signed certificate or user provi

Patrick Hener 133 Sep 28, 2022
Api-product - A basic REST-ish API that allows you to perform CRUD operations for Products

Description A basic REST-ish API that allows you to perform CRUD operations for

Abdul Salim 0 Jan 3, 2022
protoCURL is cURL for Protobuf: The command-line tool for interacting with Protobuf over HTTP REST endpoints using human-readable text formats

protoCURL protoCURL is cURL for Protobuf: The command-line tool for interacting with Protobuf over HTTP REST endpoints using human-readable text forma

QAware GmbH 19 Sep 28, 2022
A CLI tool for interacting with Kafka through the Confluent Kafka Rest Proxy

kafkactl Table of contents kafkactl Table of contents Overview Build Development Overview kafkactl is a CLI tool to interact with Kafka through the Co

Alexandre Barone 0 Nov 1, 2021
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

Gin Web Framework Gin is a web framework written in Go (Golang). It features a martini-like API with performance that is up to 40 times faster thanks

Gin-Gonic 63.2k Sep 29, 2022
A software architecture style example for APIs that utilizes the features of SOLID-Principle.

Engelbyte's Waterbyte Clean Architecture A software architecture style example for APIs that utilizes the features of SOLID-Principle. The example sho

Waterbyte 0 Feb 9, 2022
That's right - order that nice pizza 🍕 with `kubectl`

pizza-controller making kubernetes do what it was always meant to do: order pizza. https://gum.co/kubernetes-crds to get up to speed with custom resou

Ciro S. Costa 109 Apr 5, 2022
🎀 a nice lil shell for lua people made with go and lua

Hilbish ?? a nice lil shell for lua people made with go and lua It is currently in a mostly beta state but is very much usable (I'm using it right now

Hilbis Development 267 Sep 28, 2022
Style definitions for nice terminal layouts 👄

Lip Gloss Style definitions for nice terminal layouts. Built with TUIs in mind. Lip Gloss takes an expressive, declarative approach to terminal render

Charm 5k Sep 28, 2022
go program that installs and customizes ohmyzsh tmux vim via various plugins and other nice to haves

Pimp-My-Shell Table of Contents Pimp-My-Shell Install Usage About Resources Tmux Hotkeys VIM Hotkeys Adjusting Custom Aliases Mac Fix Terminal bind ke

null 9 Aug 31, 2022
Ddg - DuckDuckGo terminal search that plays nice with grep and fzf

ddg duckduckgo terminal search for use with fzf (or grep) What? With this tool y

Cauê Felchar 3 Apr 1, 2022
nice!nano holder for the lolligagger tray mount for dactyl manuforms

nice!nano holder This is a nice!nano holder for the lolligagger tray mount for Joshua Shreves Dactyl Manuform python port if you enable controller_mou

Martin Treusch von Buttlar 0 Feb 6, 2022
Turn repo with markdown files into a nice looking blog

Chameleon Chameleon is web application (blog engine) that reflects content from markdown files from a git repository. Powers articles.orsinium.dev. Fe

Life4 45 Sep 22, 2022
REST based Redis client built on top of Upstash REST API

An HTTP/REST based Redis client built on top of Upstash REST API.

Andreas Thomas 5 Jul 31, 2022