npm

Need private packages and team management tools?Check out npm Orgs. »

@stoplight/request-maker

2.4.0 • Public • Published

request-maker component

Maintainability Test Coverage

Request Maker is a Component for Studio to craft HTTP Requests, send them somewhere and display them back in the component.

Installation

Supported in modern browsers and node.

  yarn add request-maker

Usage

This library exports RequestMaker, ActionBar, ResponseEditor, and ResponseViewer component.

RequestMaker holds the state of the application. It can be initialized by providing IHttpOperation and IHttpRequest.

All request maker parameters are optional:

  • operation: IHttpOperation
  • request: IHttpRequest
  • hideRequestEditor: boolean
  • hideResposne: boolean

Properties taken from IHttpOperation:

  • method
  • path
  • servers

Properties taken from IHttpRequest:

  • method
  • path
  • baseUrl
  • headers
  • query
  • body

Properties from IHttpRequest take precedence over IHttpMethod

RequestMaker

  <RequestMaker />
  const operation = IHttpOperation = {
  id: '1',
  method: 'post',
  path: '/operationResource',
  request: {
    path: [],
    query: [],
    headers: [],
    cookie: [],
    body: {
      contents: [],
    },
  },
  responses: [],
  servers: [
    {
      url: 'http://localhost:9001',
    },
    {
      url: 'http://localhost:3000',
    },
    {
      url: 'http://example.com',
    },
  ],
  security: [],
};
 
const request: IHttpRequest<string> = {
  baseUrl: 'http://localhost:8080',
  method: 'get',
  url: '/requestResource',
  headers: {
    testHeader: 'testHeaderValue',
  },
  query: {
    testQueryParam: ['testQueryValue'],
  },
  body: '{"valid": true}',
};
  <RequestMaker operation={operation} request={request}/>

That's all you need to do. It'll manage the state for you and place the components here and there.

Using components separately

In case you want to craft your own component, you can use the parts separately, but you'll have to manage its state.

Keywords

none

install

npm i @stoplight/request-maker

Downloadsweekly downloads

4

version

2.4.0

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability