Skip to content
Open
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
65 changes: 65 additions & 0 deletions examples/static-html/9ci/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
openapi: 3.0.3
info:
title: Sample API
version: 1.0.0
description: API documentation with Stoplight-compatible x-codeSamples

paths:
/users:
get:
summary: Get all usersww
x-codeSamples:
- lang: shell
label: JavaScript (fetch22)
lib: curl
source: >
fetch("https://api.example.com/users")
.then(res => res.json())
.then(data => console.log(data));
tags: [User]
responses:
'200':
description: List of userslll

/payments:
post:
summary: Make a payment
tags: [Payment]
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
amount:
type: number
responses:
'201':
description: Payment created
x-code-samples:
- lang: curl
label: Curl11
source: |
curl -X POST "https://api.example.com/payments" \
-H "Content-Type: application/json" \
-d '{"amount": 100}'
- lang: python
label: Python (requests)
source: |
import requests
response = requests.post(
"https://api.example.com/payments",
json={"amount": 100}
)
print(response.json())
tags:
- name: User
description: Operations about users
- name: Payment
description: Payment processing
x-taggroups:
- name: Users
tags: [User]
- name: Payments
tags: [Payment]
28 changes: 28 additions & 0 deletions examples/static-html/9ci/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />

<title>Stoplight Elements example</title>
<meta name="description" content="Example site using Stoplight Elements to display docs" />
<meta name="author" content="Stoplight" />

<!-- <script src="/modules/@stoplight/elements/web-components.min.js"></script>
<link rel="stylesheet" href="/modules/@stoplight/elements/styles.min.css" /> -->

<script src="../../../packages/elements/dist/web-components.min.js"></script>
<link rel="stylesheet" href="../../../packages/elements/dist/styles.min.css" />

<style>
body {
font-family: ui-sans-serif, sans-serif;
font-size: 12px;
height: 100vh;
}
</style>
</head>
<body>
<elements-api apiDescriptionUrl="./api.yml" basePath="/"></elements-api>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface LanguageConfig {
}
export type RequestSampleConfigs = Dictionary<LanguageConfig, SupportedLanguage>;

//XXX: List of supported languages
export const requestSampleConfigs: RequestSampleConfigs = {
Shell: {
mosaicCodeViewerLanguage: 'bash',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Flex, Icon, ITextColorProps } from '@stoplight/mosaic';
import { HttpMethod, NodeType } from '@stoplight/types';
import { capitalize } from 'lodash';
import * as React from 'react';

import { useFirstRender } from '../../hooks/useFirstRender';
Expand Down Expand Up @@ -258,7 +259,7 @@ const Group = React.memo<{
elem = (
<Item
isInResponsiveMode={isInResponsiveMode}
title={item.title}
title={capitalize(item.title)}
meta={meta}
onClick={handleClick}
depth={depth}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
export const simpleApiWithTagGroups = {
swagger: '2.0',
info: {
title: 'To-dos',
description: 'Great API, but has internal operations.',
version: '1.0',
contact: {
name: 'Stoplight',
url: 'https://stoplight.io',
},
license: {
name: 'MIT',
},
},
host: 'todos.stoplight.io',
schemes: ['https', 'http'],
consumes: ['application/json'],
produces: ['application/json'],
securityDefinitions: {
apikey: {
name: 'apikey',
type: 'apiKey',
in: 'query',
description: "Use `?apikey=123` to authenticate requests. It's super secure.",
},
},
tags: [
{
name: 'Todos',
'x-displayName': 'To-dos',
},
{
name: 'Retrieval',
'x-displayName': 'Retrieve To-do Items',
},
{
name: 'Management',
'x-displayName': 'Add/remove To-do Items',
},
],
'x-tagGroups': [
{
name: 'Todos',
tags: ['Retrieval', 'Management'],
},
],
paths: {
'/todos/{todoId}': {
parameters: [
{
name: 'todoId',
in: 'path',
required: true,
type: 'string',
},
],
get: {
operationId: 'GET_todo',
summary: 'Get Todo',
tags: ['Retrieval'],
'x-internal': true,
responses: {
'200': {
description: '',
schema: {
$ref: './models/todo-full.v1.json',
},
examples: {
'application/json': {
id: 1,
name: 'get food',
completed: false,
completed_at: '1955-04-23T13:22:52.685Z',
created_at: '1994-11-05T03:26:51.471Z',
updated_at: '1989-07-29T11:30:06.701Z',
},
},
},
'404': {
$ref: '../common/openapi.v1.yaml#/responses/404',
},
'500': {
$ref: '../common/openapi.v1.yaml#/responses/500',
},
},
},
put: {
operationId: 'PUT_todos',
summary: 'Update Todo',
tags: ['Management'],
parameters: [
{
name: 'body',
in: 'body',
schema: {
$ref: './models/todo-partial.v1.json',
example: {
name: "my todo's new name",
completed: false,
},
},
},
],
responses: {
'200': {
description: '',
schema: {
$ref: './models/todo-full.v1.json',
},
examples: {
'application/json': {
id: 9000,
name: "It's Over 9000!!!",
completed: true,
completed_at: null,
created_at: '2014-08-28T14:14:28.494Z',
updated_at: '2015-08-28T14:14:28.494Z',
},
},
},
'401': {
$ref: '../common/openapi.v1.yaml#/responses/401',
},
'404': {
$ref: '../common/openapi.v1.yaml#/responses/404',
},
'500': {
$ref: '../common/openapi.v1.yaml#/responses/500',
},
},
security: [
{
apikey: [],
},
],
},
delete: {
operationId: 'DELETE_todo',
summary: 'Delete Todo',
tags: ['Todos'],
responses: {
'204': {
description: '',
},
'401': {
$ref: '../common/openapi.v1.yaml#/responses/401',
},
'404': {
$ref: '../common/openapi.v1.yaml#/responses/404',
},
'500': {
$ref: '../common/openapi.v1.yaml#/responses/500',
},
},
security: [
{
apikey: [],
},
],
},
},
'/todos': {
post: {
operationId: 'POST_todos',
summary: 'Create Todo',
tags: ['Todos'],
parameters: [
{
name: 'body',
in: 'body',
schema: {
$ref: './models/todo-partial.v1.json',
example: {
name: "my todo's name",
completed: false,
},
},
},
],
responses: {
'201': {
description: '',
schema: {
$ref: './models/todo-full.v1.json',
},
examples: {
'application/json': {
id: 9000,
name: "It's Over 9000!!!",
completed: null,
completed_at: null,
created_at: '2014-08-28T14:14:28.494Z',
updated_at: '2014-08-28T14:14:28.494Z',
},
},
},
'401': {
$ref: '../common/openapi.v1.yaml#/responses/401',
},
'500': {
$ref: '../common/openapi.v1.yaml#/responses/500',
},
},
security: [
{
apikey: [],
},
],
description: 'This creates a Todo object.\n\nTesting `inline code`.',
},
get: {
operationId: 'GET_todos',
summary: 'List Todos',
tags: ['Todos'],
parameters: [
{
$ref: '../common/openapi.v1.yaml#/parameters/limit',
},
{
$ref: '../common/openapi.v1.yaml#/parameters/skip',
},
],
responses: {
'200': {
description: 'wefwefwef',
schema: {
type: 'array',
items: {
$ref: './models/todo-full.v1.json',
},
},
examples: {
'application/json': [
{
id: 1,
name: 'design the thingz',
completed: true,
},
{
id: 2,
name: 'mock the thingz',
completed: true,
},
{
id: 3,
name: 'code the thingz',
completed: false,
},
],
},
},
'500': {
$ref: '../common/openapi.v1.yaml#/responses/500',
},
},
description: 'This returns a list of todos.',
},
},
},
definitions: {
InternalSchema: {
title: 'Internal Schema',
description: 'Fun Internal Schema',
schema: { type: 'object' },
'x-internal': true,
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as React from 'react';
import { Navigate, useLocation } from 'react-router-dom';

import { ServiceNode } from '../../utils/oas/types';
import { computeAPITree, findFirstNodeSlug, isInternal, resolveRelativePath } from './utils';
import { computeAPITree, findFirstNodeSlug } from './computeAPITree';
import { isInternal, resolveRelativePath } from './utils';

type SidebarLayoutProps = {
serviceNode: ServiceNode;
Expand Down
Loading