Skip to content

Commit

Permalink
feat(docs): updated docs content
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilmhdh committed Feb 13, 2023
1 parent df3f651 commit ed3d235
Show file tree
Hide file tree
Showing 31 changed files with 606 additions and 44 deletions.
18 changes: 17 additions & 1 deletion docs/docs/cli/cli-commands/apic-help.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# APIC Help
# Util commands

## APIC help

To get cli help over various commands

```bash
apic help
```

## Version

To get the current version of APIC cli

```bash
apic --version
```
11 changes: 11 additions & 0 deletions docs/docs/cli/cli-commands/apic-run.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# APIC Run

To run APIC cli validation against the api schema file

## Options

| Name | Flag | Desc | Required | Type | Default |
| ------- | ---- | ------------------------------------------------ | -------- | --------------- | ------- |
| apiType | -a | API schema type | true | Enum[ openapi ] | - |
| schema | | URL or local file containing the API schema file | true | String | - |
| config | | path to apic config file | false | String | ./apic |
| export | | export the final report to the given directory | false | String | - |
92 changes: 84 additions & 8 deletions docs/docs/cli/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="mac" label="MacOS" default>
Use <a>brew</a> package manaager
Use <a>brew</a> package manager
<br/>
<br/>

Add the 1-platform brew tap

```bash
brew install one-platform/apic
brew tap 1-platform/homebrew-tools
```

Now you can install the CLI

```bash
brew install 1-platform/apic
```

</TabItem>
Expand All @@ -19,31 +27,99 @@ We use cloudsmith to distribute packages
<br/>
<br/>

Add 1-platform cloudsmith repo url to your package manager

```bash
apk add --no-cache bash curl

curl -1sLf \
'https://dl.cloudsmith.io/public/OWNER/REPOSITORY/cfg/setup/bash.deb.sh' \
| sudo bash
'https://dl.cloudsmith.io/public/1-platform/apic/cfg/setup/bash.alpine.sh' \
| bash
```

Now you can install the CLI

```bash
apk add apic --update-cache
```

</TabItem>
<TabItem value="deb" label="Debian/Ubuntu">

<TabItem value="deb" label="Debian/Ubuntu" >
We use cloudsmith to distribute packages
<br/>
<br/>

Add 1-platform cloudsmith repo url to your package manager

```bash
apt-get update && apt-get install -y bash curl

curl -1sLf \
'https://dl.cloudsmith.io/public/OWNER/REPOSITORY/cfg/setup/bash.deb.sh' \
| sudo bash
'https://dl.cloudsmith.io/public/1-platform/apic/cfg/setup/bash.deb.sh' \
| bash
```

Now you can install the CLI

```bash
apt-get update && apt-get install -y apic
```

</TabItem>

<TabItem value="linux" label="RedHat/Amazon-Linux" >
We use cloudsmith to distribute packages
<br/>
<br/>

Add 1-platform cloudsmith repo url to your package manager

```bash
curl -1sLf \
'https://dl.cloudsmith.io/public/1-platform/apic/cfg/setup/bash.rpm.sh' \
| sh
```

Now you can install the CLI

```bash
yum install apic
```

If your a fedora user

```bash
dnf install apic
```

</TabItem>

<TabItem value="widows" label="Windows" >
We use scoop to distribute packages
<br/>
<br/>

Add 1-platform scoop repo url

```bash
scoop bucket add https://github.com/1-Platform/scoop-tools
```

Now you can install the CLI

```bash
scoop install apic
```

</TabItem>

</Tabs>

To make sure it's installed correctly you can run

```bash
apic help
apic --version
```

### Run against an OpenAPI
Expand Down
20 changes: 20 additions & 0 deletions docs/docs/cli/modules/env.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# Env Module

Env module can be imported from `apic/env` to set and get environment variabls.

## Functions

### setEnv

```js
import { setEnv } from "apic/env";

setEnv("key", "value");
```

### getEnv

```js
import { getEnv } from "apic/env";

const envValue = getEnv("key");
```
16 changes: 16 additions & 0 deletions docs/docs/cli/modules/exec.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# Exec Module

Exec module can be imported from `apic/exec` to execute system commands.

## Functions

### cmd

```js
import cmd from "apic/exec";

const { data, error } = cmd("....");
```

This will execute a system command.

Data key contains system output and error key contains the stderr
25 changes: 25 additions & 0 deletions docs/docs/cli/modules/overview.md
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
---
sidebar_position: 1
---

# Overview

APIC comes with some JS modules to help you write your own rule.

You can import those packages under the `apic/` namespace.

List of APIC modules

| Name | Package | Desc |
| -------------------------------------- | ------------ | ------------------------------------ |
| [Exec Module](/cli/modules/exec) | apic/exec | To run system commands |
| [Env Module](/cli/modules/env) | apic/env | To set and get environment variables |
| [Strings Module](/cli/modules/strings) | apic/strings | To check string casing |

:::caution

Right now apic doen't support importing anything else, even relative JS file.

We are still working on ways to package complex plugins.

Soon will add support to apic to support complex plugins.
:::
52 changes: 52 additions & 0 deletions docs/docs/cli/modules/strings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Strings Module

To check for string casing and some more operations not covered by the JS strings.

## Functions

### isCasing

```js
import { isCasing } from "apic/strings";

const value = "hello_world";
const check = isCasing(value, "snakecase");
```

To check whether given value is a valid provided casing.

The casing can be snakecase, camelcase, pascalcase and kebabcase.

### isPlural

```js
import { isPlural } from "apic/strings";

const value = "properties";
const check = isPlural(value);
```

### isSingular

```js
import { isSingular } from "apic/strings";

const value = "property";
const check = isSingular(value);
```

### pluralize

```js
import { pluralize } from "apic/strings";

const value = pluralize("property");
```

### singular

```js
import { singular } from "apic/strings";

const value = singular("properties");
```
10 changes: 9 additions & 1 deletion docs/docs/cli/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ It mainly validates your API schema file, runs it against the rules you have spe

## CLI Architecture

[image-to-be-added-cli-arch]
![cli-architecture](/img/cli-arch.png)

### Config

Expand Down Expand Up @@ -40,6 +40,14 @@ plugins:
</details>
:::info
Rules section points towards builtin apic rules
Where as plugins sections points towards user defined rules
:::
### Rules
Rules are the validations executed over a schema file.
Expand Down
14 changes: 14 additions & 0 deletions docs/docs/cli/rules/builtin/openapi/ status-code-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Status Code Checks

## Desc

1. Rule Name: status_code_check
2. Category: quality

Checks whether there is any invalid status code. Also can be used only allow particular set of status code in an API.

## Options

| Name | Desc | Required | Type | Default |
| -------------------- | ---------------------------------------- | -------- | -------- | ------- |
| allowed_status_codes | status code that are only allowed in api | false | String[] | [ ] |
12 changes: 12 additions & 0 deletions docs/docs/cli/rules/builtin/openapi/body-in-get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Body In Get Request

## Desc

1. Rule Name: body_in_get_req
2. Category: security

Check whether there is body in a GET request.

## Options

None
15 changes: 15 additions & 0 deletions docs/docs/cli/rules/builtin/openapi/req-body-query-case-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Schema Case Check

## Desc

1. Rule Name: schema_case_checker
2. Category: Quality

Checks for casing over a request body and query params.

## Options

| Name | Desc | Required | Type | Default |
| --------------- | ----------------------------------------------- | -------- | ------------------------------------------------- | --------- |
| req_body_casing | casing system to be followed for request bodies | false | Enum[kebabcase, snakecase, camelcase, pascalcase] | camelcase |
| params_casing | casing system to be followed for query params | false | Enum[kebabcase, snakecase, camelcase, pascalcase] | camelcase |
12 changes: 12 additions & 0 deletions docs/docs/cli/rules/builtin/openapi/unsafe-url-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Unsafe URL Character Check

## Desc

1. Rule Name: unsafe_url_character_check
2. Category: quality

Checks whether URL contains any invalid characters by web specification.

## Options

Nil
16 changes: 16 additions & 0 deletions docs/docs/cli/rules/builtin/openapi/url-case-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# URL Casing Check

## Desc

1. Rule name: url_case_checker
2. Category: quality

Checks for URL's casing.

## Options

| Name | Desc | Required | Type | Default |
| --------------- | -------------------------------------------- | -------- | ------------------------------------------------- | --------- |
| casing | casing system to be followed | false | Enum[kebabcase, snakecase, camelcase, pascalcase] | kebabcase |
| base_urls | base url followed by the schema for all URLs | false | String[] | [ ] |
| blacklist_paths | URLs to be ignored | false | String[] | [ ] |
17 changes: 17 additions & 0 deletions docs/docs/cli/rules/builtin/openapi/url-length-check.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# URL Length Check

## Desc

1. Rule Name: url_length
2. Category: quality

Checks whether API's URL is too long.

Weights are assigned to all dynamic path params like `/url/{dynamic}` that estimate how long are they generally.

## Options

| Name | Desc | Required | Type | Default |
| --------------- | ----------------------------------------------------------------------------------- | -------- | -------- | ------- |
| weight | Dynamic path params average length. Ex: `/url/{id}` the average length id could be. | false | Number | 5 |
| max_url_length | maximum allowed url length | false | Number | 75 |
| blacklist_paths | URLs to be ignored | false | String[] | [ ] |
Loading

0 comments on commit ed3d235

Please sign in to comment.