Giter VIP home page Giter VIP logo

stoplightio / elements Goto Github PK

View Code? Open in Web Editor NEW
1.5K 19.0 177.0 22.87 MB

Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.

Home Page: https://stoplight.io/open-source/elements/

License: Apache License 2.0

JavaScript 0.83% TypeScript 98.87% Shell 0.12% CSS 0.17%
api api-documentation openapi3 openapi3-1 react openapi gatsby hacktoberfest

elements's Introduction

Elements - OpenAPI Powered API Documentation

Storybook CircleCI NPM Downloads Stoplight Forest

Beautiful API documentation powered by OpenAPI and Markdown. Use these UI components to create API reference documentation, or more complete documentation with Markdown articles covering tutorials, how-to guides, etc.

Available as React Components, or Web Components, you can use Elements all together to build beautiful three-column "Stripe-esque" documentation, or stacked documentation thats easier for integrating into existing Content Management Systems with their own navigation.

Overview

๐Ÿ“– Community

Let's chat about features, ideas, what you're doing with Elements, on GitHub Discussions.

๐Ÿ‘๏ธ๐Ÿ—จ ๏ธ๏ธExamples

Stoplight Elements comes with a few example integration projects, showing you how to utilize Elements with different frameworks.

  • react-cra - An example app built using Create React App utilizing Stoplight Elements.
  • react-gatsby - An example Gatsby site utilizing Stoplight Elements.
  • angular - An angular app utilizing the Web Components distribution of Elements.
  • bootstrap - A single HTML page utilizing the Web Components distribution via a global script tag.

To run these examples yourself:

  1. Clone this repo.
  2. Go to examples folder and open an example, e.g.: examples/angular.
  3. Run yarn to install all dependencies.
  4. Run yarn start to run the example.

Note: for bootstrap example just go straight to its directory and open the HTML file.

๐Ÿ Usage

The examples will hopefully help show Elements working in close to real world situations, but the most bare bones examples of Elements can be found below.

React Component

$ npm install @stoplight/elements
import { API } from "@stoplight/elements";

<API
  apiDescriptionUrl="https://api.apis.guru/v2/specs/github.com/1.1.4/openapi.yaml"
  router="history"
/>

For more information on using Elements as a React component, head over to our React documentation.

Web Component

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Elements in HTML</title>
    <!-- Embed elements Elements via Web Component -->
    <script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
  </head>
  <body>

    <elements-api
      apiDescriptionUrl="https://api.apis.guru/v2/specs/github.com/1.1.4/openapi.yaml"
      router="hash"
      layout="sidebar"
    />

  </body>
</html>

Load this page up in your browser and you should see the GitHub REST API documented in Stoplight Elements.

For more information on using Elements as a Web Component, head over to our Web Component documentation.

๐Ÿšง Roadmap

  • API Console (a.k.a "Try it!")
  • Automatic Code Samples
  • Automatic Examples
  • React & Web Component Support
  • OpenAPI Support
    • OpenAPI v3.1
    • OpenAPI v3.0
    • OpenAPI v2.0
  • Callbacks
  • Webhooks
  • Multiple APIs (a.k.a "Dev Portal")

Submit your ideas for new functionality on the Stoplight Roadmap.

โš™๏ธ Integrations

  • Stoplight Studio - Free visual OpenAPI designer that uses Elements to preview your API descriptions on the fly.
  • Stoplight Platform - Collaborative API Design Platform for designing, developing and documenting APIs with hosted documentation powered by Elements.
  • LaravelPHP Elements - A simple API documentation package for Laravel using OpenAPI and Stoplight Elements.

๐Ÿ Help Others Utilize Elements

If you're using Elements for an interesting use case, contact us for a case study. We'll add it to a list here. Spread the goodness ๐ŸŽ‰

๐Ÿ‘ Contributing

If you are interested in contributing to Elements itself, check out our contributing docs โ‡— and code of conduct โ‡— to get started.

๐ŸŽ‰ Thanks

Elements is built on top of lots of excellent packages, and here are a few we'd like to say a special thanks to.

Check these projects out!

๐ŸŒฒ Sponsor Elements by Planting a Tree

If you would like to thank us for creating Elements, we ask that you buy the world a tree.

elements's People

Contributors

amjcraft avatar billiegoose avatar brendarearden avatar chohmann avatar daniel-white avatar dependabot-preview[bot] avatar dependabot[bot] avatar depfu[bot] avatar dotslashderek avatar jgreen44 avatar karol-maciaszek avatar kaylachun avatar lanemc avatar lottamus avatar mallachari avatar marbemac avatar marcelltoth avatar mmiask avatar mnaumanali94 avatar nezteb avatar p0lip avatar pamgoodrich avatar paulatulis avatar philsturgeon avatar pytlesk4 avatar sb-akshaythakar avatar ssspear avatar stoplight-bot avatar stoplightsupport avatar xvincentx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elements's Issues

Rework Blog Post: components, template, Netlify config

Overhaul the current way Stoplight.io blog and blogposts are rendered

  • Rely on first iteration of component catalogue to update all components involved with showing a blog post (hero, md file, related pages, etc.)
  • Rework Netlify-dependent configuration so that all naming conventions are specified, standardized, and clear to anyone working in Admin portal (use more robust help text and correct assignment of required parameters to accomplish this)

Compile SCSS to CSS

User story.
As a developer, I can use @stoplight/elements without needing to compile the SCSS files myself.

Is your feature request related to a problem?
BigCommerce and PagerDuty are using these React components in their GatsbyJS sites. Prior to v5, we were compiling the SCSS files into a single CSS bundle that they are including in their build.

Describe the solution you'd like
Compile the SCSS files to CSS using node-sass or similar.

Add server variables to http service docs

User story.

As a user, I can view the server variables defined by the http service, so that I can use the default value and enums when making requests.

Describe the solution you'd like

When looping over the http service's servers, we should also display all of the server variables with the description, default value, and enums.

For the UI, I suggest putting the server variables in a table underneath the server.

For example:

My Server - https://{subdomain}.example.com/{baseUrl}

this is the server's description

Variable Description
subdomain this is the description for the subdomain.
default: "foo" enum: "foo", "bar"

https://github.com/stoplightio/elements/blob/master/src/components/HttpService/index.tsx#L29-L36

Additional Context

Error: ResizeObserver loop limit exceeded

Sentry Issue: STUDIO-DESKTOP-20

Error: ResizeObserver loop limit exceeded
  at None (/docs-preview/gh/stoplightio/studio)

ResizeObserver is being in Elements by @rehooks/component-size: https://github.com/stoplightio/elements/blob/master/src/components/Docs.tsx#L4

Description

Here's a similar issue in a library that is also using ResizeObserver: souporserious/react-measure#104. They fixed the issue by canceling the animation frame when the component is unmounted: https://github.com/souporserious/react-measure/pull/118/files#diff-2e71677d1028fc71469e53aa449f42d5R41

Expected

To fix the issue, we likely need to fork the @rehooks/component-size repo, wrap the following lines in a requestAnimationFrame and cancel the animation when the component is unmounted:
https://github.com/rehooks/component-size/blob/master/index.js#L49-L52

Docs content should scroll top when navigating between pages

Describe the bug

When navigating between pages, you are left at the same scroll position rather than being scrolled back to the top of the page. This is because the Page component is using a ScrollContainer which has a special scrollToTop function we're not utilizing: https://github.com/xobotyi/react-scrollbars-custom#instance-methods

To Reproduce

  1. Open Prism docs: https://stoplight.io/p/docs/gh/stoplightio/prism
  2. Scroll to the bottom of the content
  3. Click to another page in the sidebar
  4. Notice you're still at the bottom of the page

Expected behavior

You should be scrolled to the top of the page on navigation

Screenshots

2019-08-08 10 13 47

Additional context

Here's where the scroll container lives: https://github.com/stoplightio/elements/blob/master/src/components/Page.tsx#L138-L148

Suggest updating the ScrollContainerWrapper to grab the react-scrollbars-custom instance and call instance.scrollToTop() whenever the Page srn changes.

Could look something like this:

const ScrollContainerWrapper: React.FunctionComponent<{
  srn?: string;
  scrollInnerContainer?: boolean;
  shadows?: boolean;
}> = ({ srn, scrollInnerContainer, children, shadows = false }) => {
  const [scrollbarInstance, setScrollbarInstance] = React.useState();

  React.useEffect(() => {
    if (scrollbarInstance) {
      scrollbarInstance.scrollToTop();
    }
  }, [scrollbarInstance, srn]);

  if (!scrollInnerContainer) {
    return <>{children}</>;
  }

  return (
    <ScrollContainer
      ref={ref => {
        setScrollbarRef(ref);
      }}
      shadows={shadows}
    >
      {children}
    </ScrollContainer>
  );
};

Add support for multiple project groups

User story.
As a user, I can pass a specific group to the Container components, so that the correct group's data is fetched.

Describe the solution you'd like

  • Update the Container components to take an optional "group" property
  • Update the data hooks to take an optional "group" argument
  • Update the widgets to take an additional group property

Docs Version Selector

User story.
As a users, I can see a dropdown containing all the versions of the current node, so that I can navigate between them.

Describe the solution you'd like

We allow users to create multiple versions of a given node via a version number in the file path.

For example, imagine you have the following two files:

/error.v1.yaml
/error.v2.yaml

The analyzer will create a single "node" with two versions. The result will look something like:

{
  baseUri: "/error.yaml",
  version: "2",
  versions: [
    {
        uri: "error.v2.yaml",
        version: "2",
    },
    {
        uri: "error.v1.yaml",
        version: "1",
    },
  ]
}

Explorer___Stoplight

Describe the solution you'd like

Similar to what we do in Platform Explorer's NodeReadView component, let's copy the following code over to Docs and render it in the PageHeader component. Once the code has been moved over to the PageHeader, we can remove it from the Explorer's NodeReadView.

Keep in mind you won't be able to copy over the version selector's "onChange" handler since it will be different in Docs. We will likely need some way to pass an onChangeSrn handler into the Provider component OR maybe we can use the useComponents() hook to get the link component?.

[Dependencies]: highlight and show properties for active node edges

function getEdgesFromRefMap(nodeId: string, activeNodeId: string; refMap: IGraphNodeData['refMap']): IVisGraphEdge[]

Unable to add nonstandard header

To Reproduce

  1. Open the Request Maker -> with operation story
  2. Navigate to the Headers tab
  3. Click the name column in an empty row.
  4. Type asd.
  5. Hit ENTER or click the set custom... option.
  6. Navigate to the Body tab and back.

Expected behavior
The asd header still in the list.

Actual behavior
The name asd is gone, there is only an empty row.

Navigating to "/" should load the first node

Describe the bug

We have logic in place to redirect your to the first node if you land on the root of the docs. We should update this logic to also redirect you if you land on "/": https://github.com/stoplightio/elements/blob/master/src/containers/Hub.tsx#L29-L37

To Reproduce

  1. Open http://stoplight.io/p/docs/gh/stoplightio/studio-demo/
  2. Notice the slash at the end of the URL
  3. Notice you land on a "not found" page

Expected behavior

  1. Open https://stoplight.io/p/docs/gh/stoplightio/studio-demo
  2. Notice there's no slash at the end of the URL
  3. Notice you land on the first node

This is the expected behavior when the "uri" property is both empty or "/"

v6 Proposed Changes

v6

Architecture

Everything must be wrapped in the <Provider /> container. It provides the rest of the components with important information such as:

  • Stoplight API host
  • current workspace, project, branch and uri
  • current node data

All data fetching should happen within the Container components which feed data into the Components for rendering. This allows users to simply render the Container components without needing to make any API requests. Alternatively if they are making the API calls themselves (link in Platform), they can pass that information directly into the Components for rendering.

Containers

React components that communicate with the Stoplight API and feed data into the dumb components for rendering

/src/containers/Changelog
/src/containers/Dependencies
/src/containers/Docs
/src/containers/Provider
/src/containers/RequestMaker
/src/containers/Search
/src/containers/TableOfContents

Components

Dumb components that receive data and render

/src/components/Changelog
/src/components/Content
/src/components/Dependencies/Inbound
/src/components/Dependencies/Outbound
/src/components/Docs/Article
/src/components/Docs/HttpOperation
/src/components/Docs/HttpService
/src/components/Docs/Model
/src/components/RequestMaker
/src/components/Search
/src/components/Tab
/src/components/TableOfContents

Layout

<Provider 
  workspace="bigcommerce.stoplight.io" 
  project="dev-docs" 
  uri="reference/bigcommerce_subscribers_api.oas2.yml"
>
  <div className='flex'>
    <TableOfContents filter={{ startsWith: "reference" }} />

    <Content className='flex-1'>
      <Tab title="Docs">
        <Docs />
      </Tab>

      <Tab title="Try It" filter={{ type: "http_operation" }}>
        <RequestMaker />
      </Tab>

      <Tab title="Dependencies" filter={{ type: "model" }}>
        <Dependencies />
      </Tab>

      <Tab title="Changelog" >
        <Changelog />
      </Tab>
    </Content>
  </div>
</Provider>

Theming

No table of contents on mobile devices

From customer (ticket here):

The other issue I'm seeing is that the TableOfContents disappears on mobile devices. I thought this was maybe my site doing this magically but the entire element is removed from the page when the width hits the mobile media width. Not sure what is happening there.

Is this a known issue?

Add link to storybook in README

Chore summary

Soon our customers will need documentation for the components in this repo. We can utilize Storybook to help too

Tasks

  • Get storybook rendering in GitHub Pages again
  • Clean it up so it is presentable to customers

Outbound Dependencies

User story.
As a docs reader, I can view the outbound dependencies for the current model.

Is your feature request related to a problem?
Customers want to be able to see how their model is connected to other models in their Org.

Describe the solution you'd like
When viewing a model, there should be another tab called "Dependencies" that shows a tree of outbound dependencies.

Additional context
You should be able to enable/disable the Dependencies tab by passing in a prop to the <Page /> component.

This issue is limited to outbound dependencies though in the future we will likely add inbound dependencies and add this tab for operations, articles, etc.

image

image

image

Request Maker Tab index is broken in headers

If I go to the headers tab and I write an header โ€” when I tab I expect to go to the value text box โ€” instead it goes on a different place and it kind of destroys the flow.

It works ok in the Query tab

Extract TableOfContents component to UI-Kit

Chore summary

We're starting to use the TableOfContents component in more places than just Docs, so it makes sense for us to make it a bit more generic and move it to @stoplight/ui-kit. BUT we should keeps the parts of the TableOfContents components that deal with Project nodes in this repo (see below).

Tasks

  • Move the ITableOfContents interface to ui-kit and remove the items prop:
export interface ITableOfContents {
- // List of items that will be computed into the tree structure
-  items?: IProjectNode[];

  contents: IContentsNode[];

  // Padding that will be used for (default: 10)
  padding?: string;
  className?: string;

  // Title of project
  title?: string;

  // Controls for the drawer functionality on mobile
  isOpen?: boolean;
  onClose?: () => void;

  // Mobile breakpoint, default (true) is 786px, false disables Drawer
  enableDrawer?: boolean | number;
}
import { TableOfContents as UIKitTableOfContents } from '@stoplight/ui-kit';

export const TableOfContents: React.FunctionComponent<ITableOfContents> = ({
  items,
  srn,
  ...props,
}) => {
  const contents = useComputeToc(items, srn);
  return <TableOfContents contents={contents} {...props}  />
};
  • On IContentsNode, replace the srn prop with isActive and add an optional href prop:
export interface IContentsNode {
  name: string;
  depth: number;
-  srn?: string;
+ isActive?: boolean;
+ href?: string;
  type?: 'divider' | 'group';
}
export function useComputeToc(nodes: IProjectNode[], srn?: string) {
contents.push({
  name: node.name,
-  srn: node.srn,
+ isActive: srn === node.srn,
+ href: srn,
  depth: parts.length - 1,
});

Example: (note the addition of "href" and the "isActive" prop to the last Github)

<TableOfContentsComponent
  contents={[
    {
      name: "Personal",
      depth: 0,
      type: "divider",
    },
    {
      name: "My Projects",
      depth: 0,
      icon: "star",
      href: '/projects/username',
    },
    {
      name: "GitHub",
      depth: 0,
      icon: "github",
      href: '/projects/username/github',
    },
    {
      name: "Stoplight Next",
      depth: 0,
      icon: "gitlab",
      href: '/projects/username/stoplight-next',
    },
    {
      name: "SendGrid",
      depth: 0,
      type: "divider"
    },
    {
      name: "GitHub",
      depth: 0,
      icon: "github",
      href: '/projects/sendgrid/github',
    },
    {
      name: "Stoplight Next",
      depth: 0,
      icon: "gitlab",
      href: '/projects/sendgrid/stoplight-next',
    },
    {
      name: "XYZ Corp",
      depth: 0,
      type: "divider"
    },
    {
      name: "GitHub",
      depth: 0,
      icon: "github",
      isActive: true,
      href: '/projects/xyz-corp/github',
    }
  ]}
/>

Result:

image

Resize dependency graph to fit screen when toggling fullscreen

Description

When a user goes into fullscreen, they have a lot more space and will often zoom out to fit all the nodes in their screen. When they exit fullscreen, they are left zoomed out super far and are required to zoom back in. This is similar to the issue described here: https://github.com/stoplightio/platform-internal/issues/121#issuecomment-562262430

Reproduce

  1. Open the Dependency storybook: https://stoplightio.github.io/elements/?path=/story/components-page--model
  2. Zoom in and hit fullscreen
  3. Notice when in fullscreen you're still zoomed in super far

Expected
When toggling fullscreen, the graph should be reset to fit the graph.

Implementation Notes
We use the following two libraries to build the graph:

vis-network has a function called fit() that redraws the graph to fit the screen that we can call whenever we toggle fullscreen. In order to access the vis-network, we need to pass a callback function to the getNetwork prop in react-graph-vis and set the returned value to a mutable ref using React's useRef hook.

  1. Start by installing the vis-network types package. This will help with the typescript typings:
yarn add -D @types/vis
  1. Import the Network typings at the top of the file Dependencies component so we can access the typings: https://github.com/stoplightio/elements/blob/master/src/components/Dependencies/index.tsx#L4
import { Network } from 'vis';
  1. Retrieve the mutable ref by using React's useRef hook at the top of the Dependencies component: https://github.com/stoplightio/elements/blob/master/src/components/Dependencies/index.tsx#L72
const visNetwork = React.useRef<Network>();
  1. Pass a callback function into the getNetwork property in the react-graph-vis component so that we can set the vis-network class on our mutable ref: https://github.com/stoplightio/elements/blob/master/src/components/Dependencies/index.tsx#L147-L160
      <Graph
        id={node.srn.replace(/[^a-zA-Z]+/g, '-')}
        graph={visGraph}
        events={{
          click: onClickNode,
          stabilizationProgress: (data: any) => {
            setIsStable(data.iterations);
          },
          stabilized: (data: any) => {
            setIsLoading(false);
          },
        }}
        getNetwork={(network: Network) => {
          visNetwork.current = network;
        }}
        options={visGraphOptions}
      />
  1. Whenever the fullscreen toggle is clicked, call vis-network's fit() function to re-size the graph: https://github.com/stoplightio/elements/blob/master/src/components/Dependencies/index.tsx#L138-L144
        <Button
          minimal
          small
          active
          icon={<Icon icon={isFullScreen ? 'minimize' : 'fullscreen'} iconSize={10} />}
          onClick={() => {
            setIsFullScreen(!isFullScreen);

            if (visNetwork.current) {
              visNetwork.current.fit();
            }
          }}
        />
  1. Test it out to make sure it works! You should be able to zoom in really far. Then clicking the fullscreen toggle should reset your graph to fit the screen.

Allow adding buttons to the Page header

In https://github.com/stoplightio/app-gen3/issues/399 we want to be able to use the Page component but its currently missing support for adding buttons.

Suggest updating the Page component to look something like this:

export interface IPage extends IErrorBoundary {
  type: NodeType;
  data: any;

  name?: string;
  srn?: string;
  version?: string;
  versions?: string[];

  headerRight?: React.FunctionComponent

  padding?: string;
  className?: string;
  shadows?: boolean;
  scrollInnerContainer?: boolean;
}

We will also need to support adding these buttons via the Page container too:

export interface IPage {

Explorer___Stoplight

Update @stoplight/types to v11

Chore summary

Review the breaking changes from stoplightio/types#50 and update the relevant locations

Tasks

  • Update @stoplight/types to the latest 11.x release and any required changes
  • Update studio-internal when the change from this PR is merged
  • Update app-gen3 when the change from this PR is merged

Docs -> Display examples for model results

User story.
As an API developer, it would be helpful to be able to see examples from the model view in Explorer Read Panel, Studio Read Panel, Published Docs, and Docs Preview.

Solution

Update @stoplight/elements to include tabs for each example for a Model. You can use the markdown builder to add the tabs via markdown here: https://github.com/stoplightio/elements/blob/master/src/components/Docs.tsx#L43-L56

Suggest using markdown tabs and adding "Schema" as the first tab then a tab for each example.

Here's the relevant code to update: https://github.com/stoplightio/elements/blob/master/src/components/Docs.tsx#L49

UX: Tab does not insert header name suggestion

This one is super-annoying for any non-novice user (which - I'm assuming - 99% of our users are).

To reproduce

  1. Launch the Storybook, navigate to components / Request Maker / with operation.
  2. Go to Headers
  3. Start typing "acc" into a new line's "name" cell. (as if you were trying to create an "Accept" header.
  4. Verify that the "Accept" suggestion is highlighted in the popup.
  5. Hit Tab to accept it.

Expected outcome

The suggestion gets accepted -> The name field gets populated with the word "Accept" and the popup disappears.

Actual outcome

The focus gets redirected to the next field in line, the value field, without accepting the suggestion, leaving "acc" in the name field. This is unexpected.

Investigate using @zeit/swr

Chore summary

We have a custom hook for managing request data: https://github.com/stoplightio/elements/blob/master/src/hooks/useRequest.tsx. It works fine, but it would be nice to not worry about having to maintaining it.

I found this repo the other day which looks promising but still need to investigate if it will fit all of our needs: https://github.com/zeit/swr

Tasks

Additional context

  • Needs to support making paginated requests to the /project.nodes endpoint
  • Needs to support client side caching of request/response data

Fix C# code generation

Issue

Because of my extensive .NET background, I was interested in what happens if I select C# in the CodeGenerator inside RequestMaker.

Unfortunately, it's bad. Not 100% useless, but maybe 95%.

  1. It does not actually generate pure .NET core, but code for RestSharp, a library that most people don't use. (The built-in HttpClient class is pretty good for most use cases.)
  2. It generates synchronous IO code, which has been heavily discouraged for the last ~5 years.

Proposal

Having a(n async) RestSharp option is not bad, but we definitely want a HttpClient code generator if we'd like this tool to be useful for C# developers.

And I believe the code generator is a very important feature of our RM component, so this is something to be fixed.

Problem

Now there is a problem. Kong's httpsnippet already has an open PR, that is supposed to fix this, and generate - not 100% optimal, but correct - C# code: Kong/httpsnippet#149

But that repo seems to have been abandoned, or at least not maintained well. I would really like to work on fixing this - I still like .NET ๐Ÿ˜Ž - but now what do I do?

Improve Sidebar tree

User story.

As a user reading the docs, I want to see visual cues for menu items, so that I can quickly identify them.

Is your feature request related to a problem?

Currently our sidebar does not render any additional metadata for things like operations. It's not consistent with the Studio sidebar and it's making it harder to identify operations.

This is how it looks now

image

Describe the solution you'd like

Render metadata next to the sidebar items:

  • method label (get post etc)
  • or icon (model icon, api icon etc)

Additional context

Can look similar to this:

image

Segfault after sending request in "Try it"

Describe the bug
When I click "Send" for anything in our API in "Try it" studio crashes with segfault.

To Reproduce
Happens even with the smallest version of our API: api.zip. Host is internal deployment (we don't have external facing hosts)
I suspect SSL validation: even though we use HTTPS, for test environments we need to disable SSL validation in clients.

For Petstore example "Try it" works fine.

logs:

โžœ ./stoplight-studio-linux-x86_64_f5650f59acd0a03c6efb7de930c1f9b8.AppImage 
(electron) 'getName function' is deprecated and will be removed. Please use 'name property' instead.
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false".  It will change to be "true" in Electron 9.  For more information please check https://github.com/electron/electron/issues/18397
00:28:19.385 โ€บ Checking for update
00:28:19.432 โ€บ Generated new staging user ID: 55d69007-36a2-51b7-9bb0-3d77f797199b
00:28:20.750 โ€บ Update for version 1.10.2 is not available (latest version: 1.10.2, downgrade is allowed).
Segmentation fault (core dumped)

`/var/log/syslog/

Mar 22 00:28:42 aviskase-xps15 kernel: [24293.586531] stoplight-studi[22637]: segfault at 8 ip 0000563bc7977b4d sp 00007ffdb0437ca0 error 4 in stoplight-studio[563bc7970000+53ce000]

Environment (remove any that are not applicable):

  • Studio version: 1.10.2
  • OS: Ubuntu 19.10

Improve try it out

User story.
As a user, I can tweak the request before trying it out.

Is your feature request related to a problem?

Describe the solution you'd like

The improved Try It Out component should allow changing:

  • security scheme
  • toggle mock on/off
  • change base url (?)
  • modify params (?)
  • allow adding headers

Additional context

Issues with fs library?

Customer using the elements library ran into the following issue when integrating recently:

But also, elements depends on json-ref-readers and prism-http both of which are using node's fs library, which obviously isn't served in the browser. To get around this I had to mock out the fs library so that it is returned as "empty". I did this in my webpack config.

Is this something that we should fix at the library level?

cc @lottamus

Validation UI tweaks part 2

@marcelltoth @XVincentX I think this looks good for now though I don't think the error/warning message needs to be italic. Does it look bad if they're normal font?

I'm still leaning towards a flat list UI similar to what we're doing with the Spectral lint results. We could show the errors/warnings on the specific property lines within the code view too. We can do this later on when Studio supports "request" files though.

image

image

We should also consolidate the background colors of the "apply changes" UI in Studio with the validations background. https://github.com/stoplightio/platform-internal/blob/474c91635f611b8de60197f696824f9acad36e7a/packages/studio/src/components/ReadPanel/MarkdownComponents.tsx#L226-L238

image

Originally posted by @lottamus in #271 (comment)

TableOfContents Mobile Support

In app-gen3 we've added support for rendering the table of contents component on mobile screens. We should pull this functionality into the TableOfContents component so it can be used in the JS widgets and by customers such as BigCommerce who are using the React components.

https://github.com/stoplightio/app-gen3/blob/0893a6107da3c6a23d6bd874183abd49779cb1ba/components/Docs/Project.tsx#L120

  • When mobile is detected, return TableOfContents wrapped in a Drawer
  • Drawer can be opened/controlled via a prop that is passed into the TableOfContents component. This is useful so the end user can control opening/closing the sidebar via another component such as a button in the header
  • Add support for passing a title/header to be displayed at the top of the drawer

2019-09-11 11 10 46

HTTP Request Maker Variables

User story.
As a {user_type}, I can do {some_user_action}, so that I can {some_user_value}.

Is your feature request related to a problem?
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Additional context
Add any other context or screenshots about the feature request here.

Add search container and component

User story.

As a developer using @stoplight/elements, I can use the <Search /> component, so that I can provide search to my docs.

Describe the solution you'd like

Additional context

Search Container should have the following interface for props:

interface ISearchContainerProps {
  value: string;
  isOpen: boolean;
  onClose?: () => void;
  onReset?: () => void;
  srn?: string;
  group?: string;
  pinned?: boolean;
}

interface ISearchComponentProps {
  value: string;
  nodes: string;
  isOpen: boolean;
  onClose?: () => void;
  onReset?: () => void;
}

Add icons support to TableOfContents component

Currently our TableOfContents component doesn't support icons. We should support passing an icon mapping to the Provider and/or adding an icon directly to the contents items:

Example:

<TableOfContentsComponent
  contents={[
    {
      name: "Personal",
      depth: 0,
      type: "divider",
    },
    {
      name: "My Projects",
      depth: 0,
      icon: "star",
    },
    {
      name: "GitHub",
      depth: 0,
      icon: "github",
    },
    {
      name: "Stoplight Next",
      depth: 0,
      icon: "gitlab",
    },
    {
      name: "SendGrid",
      depth: 0,
      type: "divider"
    },
    {
      name: "GitHub",
      depth: 0,
      icon: "github",
    },
    {
      name: "Stoplight Next",
      depth: 0,
      icon: "gitlab",
    },
    {
      name: "XYZ Corp",
      depth: 0,
      type: "divider"
    },
    {
      name: "GitHub",
      depth: 0,
      icon: "github",
    }
  ]}
/>

Result:

image

Tasks

export interface IProvider {
  host?: string;
  token?: string;
  components?: IComponentMapping;
  icons?: Dictionary<IconName, NodeType>;
}
export interface IContentsNode {
  name: string;
  depth: number;
  srn?: string;
  type?: 'divider' | 'group';
  icon?: IconName;
}
contents.push({
  name: "Example",
  depth: 0,
  type: 'group',
  icon: icons[node.type]
});

Add/modify *Prefer* HTTP header when tweaking prism configuration

Proposal

When tweaking the different Prism options the Request Maker should automatically adjust the value of the Prefer header so library-based and hosted-instance-based mocking works the same.

Design considerations:

  • Derived state should be avoided. I would make the header the primary "source of truth", and prismConfig would become a computed value. The switches would just call an action that changes the header.
  • There is a small functional gap in the configurability of prism through HTTP. Right now there are some properties that are not configurable per-request, and this will not be addressed by the Prefer header PR. These are: Validate Request, Validate Response, Check Security. I assume these will need to be exposed through Prefer header settings, don't they?

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.