poc for swagger in docs

This commit is contained in:
Deborah Barnard
2022-04-19 16:48:11 +01:00
parent 3fa1b44039
commit b5bdc962bb
7 changed files with 347 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
hide:
- toc
---
!!swagger n8n-public-api-v1.yml!!

View File

@@ -0,0 +1,5 @@
---
template: api.html
hide:
- toc
---

0
docs/api/index.md Normal file
View File

View File

@@ -0,0 +1,305 @@
---
openapi: 3.0.0
info:
title: Public n8n API
description: n8n Public API
termsOfService: https://n8n.io/legal/terms
contact:
email: hello@n8n.io
license:
name: Apache 2.0 with Commons Clause
url: https://github.com/n8n-io/n8n/blob/master/packages/cli/LICENSE.md
version: 1.0.0
externalDocs:
description: Find out more about Swagger
url: http://swagger.io
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/RicardoE105/n8n/1.0.0
- url: /api/v1
tags:
- name: users
description: Operations about user
externalDocs:
description: Find out more about our store
url: http://swagger.io
paths:
/users:
get:
x-eov-operation-id: getUsers
x-eov-operation-handler: v1/handlers/Users
tags:
- users
summary: Retrieve all users
description: Retrieve all users from your instance. Only available for the instance owner
parameters:
- name: limit
in: query
description: The maximum number of items to return
required: false
schema:
type: number
example: 100
default: 100
- name: cursor
in: query
description: Paginate through users by setting the cursor parameter to a nextCursor attribute returned by a previous request's response. Default value fetches the first "page" of the collection. See pagination for more detail
required: false
style: form
explode: true
schema:
type: string
example: MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA
- name: includeRole
in: query
required: false
style: form
explode: true
description: Whether to include the role information the user object
schema:
type: boolean
example: false
default: false
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetailsResponse'
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
x-eov-operation-id: createUsers
x-eov-operation-handler: v1/handlers/Users
tags:
- users
summary: Invite a user
description: Invites a user to your instance. Only available for the instance owner.
operationId: createUser
requestBody:
description: Created user object
content:
application/json:
schema:
$ref: '#/components/schemas/UserInformation'
required: true
responses:
"200":
description: A User object
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/UserInformation'
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/users/{identifier}:
get:
x-eov-operation-id: getUser
x-eov-operation-handler: v1/handlers/Users
tags:
- users
summary: Get user by ID/Email
description: Retrieve a user from your instance. Only available for the instance owner.
operationId: getUser
parameters:
- name: identifier
in: path
description: The ID or email of the user
required: true
schema:
type: string
format: identifier
- name: includeRole
in: query
required: false
schema:
type: boolean
example: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/UserInformation'
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
x-eov-operation-id: deleteUser
x-eov-operation-handler: v1/handlers/Users
tags:
- users
summary: Delete user by ID/Email
description: Deletes a user from your instance. Only available for the instance owner.
operationId: deleteUser
parameters:
- name: identifier
in: path
description: The name that needs to be deleted
required: true
schema:
type: string
format: identifier
- name: transferId
in: query
description: ID of the user to transfer workflows and credentials to.
required: false
schema:
type: string
- name: includeRole
in: query
required: false
schema:
type: boolean
example: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/UserInformation'
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
"404":
description: User not found
components:
schemas:
Error:
required:
- code
- description
- message
type: object
properties:
code:
type: string
message:
type: string
description:
type: string
UserInformation:
required:
- email
type: object
properties:
id:
type: string
readOnly: true
example: 123e4567-e89b-12d3-a456-426614174000
email:
type: string
format: email
example: jhon.doe@company.com
firstName:
maxLength: 32
type: string
description: User's first name
readOnly: true
example: jhon
lastName:
maxLength: 32
type: string
description: User's last name
readOnly: true
example: doe
isPending:
type: boolean
description: Whether the user finished setting up the invitation or not
readOnly: true
createdAt:
type: string
description: Time the user was created
format: date-time
readOnly: true
updatedAt:
type: string
description: Last time the user was updaded
format: date-time
readOnly: true
globalRole:
$ref: '#/components/schemas/RoleInformation'
UserDetailsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/UserInformation'
nextCursor:
type: string
description: Paginate through users by setting the cursor parameter to a nextCursor attribute returned by a previous request. Default value fetches the first "page" of the collection.
nullable: true
example: MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA
RoleInformation:
type: object
properties:
id:
type: number
readOnly: true
example: 1
name:
type: string
example: owner
readOnly: true
scope:
type: string
readOnly: true
example: global
createdAt:
type: string
description: Time the role was created
format: date-time
readOnly: true
updatedAt:
type: string
description: Last time the role was updaded
format: date-time
readOnly: true
responses:
NotFound:
description: The specified resource was not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unauthorized:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Forbidden:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-N8N-API-KEY
security:
- ApiKeyAuth: []

View File

@@ -53,7 +53,10 @@ markdown_extensions:
permalink: "#"
plugins:
- search
# https://github.com/oprypin/mkdocs-literate-nav
- literate-nav
# https://github.com/bharel/mkdocs-render-swagger-plugin
- render_swagger
nav:
- Using n8n:
- Welcome: index.md
@@ -181,4 +184,8 @@ nav:
- Execution data: hosting/scaling/execution-data.md
- Execution modes and processes: hosting/scaling/execution-modes-processes.md
- Configuring queue mode: hosting/scaling/queue-mode.md
- API:
- The n8n public API: api/index.md
- Endpoint reference using plugin: api/api-reference-1.md
- Endpoint reference using Swagger UI directly: api/api-reference-2.md
- Contributing: contributing.md

23
overrides/api.html Normal file
View File

@@ -0,0 +1,23 @@
{% extends "main.html" %}
{% block extrahead %}
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" />
{% endblock %}
{% block content %}
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossorigin></script>
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-standalone-preset.js" crossorigin></script>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
layout: "StandaloneLayout",
});
};
</script>
{% endblock %}

View File

@@ -1 +1,2 @@
mkdocs-literate-nav==0.4.1
mkdocs-render-swagger-plugin==0.0.3