Skip to content

Commit

Permalink
Scaffolding to connect mock OpenApi spec to API Spec tab in docs (#12)
Browse files Browse the repository at this point in the history
## Summary
Adding a mock `mock.json` file and checking that it gets added to the docusaurus tabs.

You generate the docs by referencing the spec file location in the `docusaurus.config.ts` under the `plugins` part and then running `yarn docusaurus gen-api-docs all`

The reason I used a `mock.json` file instead of using the production ones (`model.json`) is that they don't currently have everything needed to properly compile the static doc files (`<name>.api.mdx`). What is missing is:
- summary
- operation

I will add these in later PRs this stack in the `protoc_plugin.py` file to ensure these are generated with that (https://app.graphite.dev/github/pr/lastmile-ai/lmai/888/Add-summary-and-operationId-and-tags-to-model-json-when-generating-OpenAPI-spec-from-protobufs). We also don't have any examples in the schema which isn't a blocker just nice to have in the docs.

We'll need to do a bunch of changes to the `model.json` files that weren't generated from proto files, since we used doc strings in the path endpoint itself instead of specifying it directly into the `model.json`, but we can also do that later

## Changelist
- all files under `docs/api` except `index.md` were autogenerated!
- also converted `docusaurus.config.js` `and sidebars.js` to typescript files

## Test Plan
```bash
yarn docusaurus gen-api-docs all # You can also replace "all" with a specific ID for the `"id":` field under `plugins--> 'docusaurus-plugin-openapi-docs'`
```
Docs tab shows up. We can adjust content and nesting structure later.

<div class='graphite__hidden'>
          <div>🎥 Video uploaded on Graphite:</div>
            <a href="https://app.graphite.dev/media/video/N4CMfFKE7hFMNsyItsnM/aa00e729-8ac8-4189-95e7-3a149422553e.mp4">
              <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/N4CMfFKE7hFMNsyItsnM/aa00e729-8ac8-4189-95e7-3a149422553e.mp4">
            </a>
          </div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/N4CMfFKE7hFMNsyItsnM/aa00e729-8ac8-4189-95e7-3a149422553e.mp4">Screen Recording 2024-10-03 at 00.34.52.mp4</video>

---
  • Loading branch information
rossdanlm authored Oct 3, 2024
2 parents f6f3b91 + 3a2203a commit 23b3783
Show file tree
Hide file tree
Showing 10 changed files with 4,232 additions and 2,008 deletions.
232 changes: 232 additions & 0 deletions website/docs/api/execute-fine-tune-job.api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
---
id: execute-fine-tune-job
title: "Execute Fine-Tune Job"
description: "Execute a fine-tune job with the given parameters"
sidebar_label: "Execute Fine-Tune Job"
hide_title: true
hide_table_of_contents: true
api: eJy1VWtv2jAU/SuRP5OR0vUxvtGOSlRFRTTrpCE0meRC3CZ2Zju0NOK/714nQChoUydNQuDH8X2ecymZ5QvDuhN2IyR4YSGFXLBpi6kcNLdCyUHMugxeISosEAYhcKtmrMViMJEWOYEQ0q8gHvfmiPItwrwnNfNehE08m4C3EEuQXs41z8CCNmjB4BMt7Ar9l+wKuAaNy+ka/Wv4VYCxVyrG25JFSlqQlpY8z1MRudjaT4Z8l8xECWScVnaVA0ajZk8QWXSRa8rECjB0K+IGxlhNya7XLcyPZ3kKG8iRfP0agteIt8ISepN0Azeu4karZFeDyZU0lfNOENDPftkeiigCY+ZF6m1LjmH/z3zRugZuIe7Zw9sWmyudcbxhMWJ8KzKgJ0Uef/SJ86L04HgMxnJbmKNXSi+4FG9b+m0gk51HWaQpmyJ2KYyYidSR6DAwkEVG70bjwWMv7OPJsD+86o/x6Ue7vlc17GXn1A/O/eAiPAm6AX1+sL0qvYec1ZBGVVhhQPsXl1+Ckw7bVYRd3w9Hd/2w/5Ud1oIO/NPPZ+cXl2w/+22Sf+FnxUhHUESiFhNFdnNlHH+4TXDX5rlod9q8sOonLHnazlQMKSmbhP2i9DPo9tGpgCktSd2o453AH4ivFSU3Mt82K7E2p3cOgvtZBWjVi5sNt26/h06rpIHxbjr0PyhdIefKea9LdMeNHYoUvN7A640G3mPnYLQdQrretcqwjihRmmOUcAXtfArICRUz406qkmeNTngUl0+BeUeGaGPO/dM8rStq4dW285QL6ZSrU7JcNXaC40QgkpLcNhfXR9pL8jlsMDY1IaagpbKccQPfdLpe0zF2RK+qti+5FnxG5Z2QRhPgsZvsJXsGYup1laUfUrwETwuK+2DSrVubFz2ckrn9I3baIPPo/iEkBtX/HpQdnmr+gof03WUkLVd1R0p3VrKUy0XBF4StbBLfsExJg67v6Omyqq+4XDUixPI4RKieQWKJWnUqlvYYLhr/DdcsjEU=
sidebar_class_name: "post api-method"
info_path: docs/api/lastmile-ai-api-v-2
custom_edit_url: null
---

import ApiTabs from "@theme/ApiTabs";
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
import MimeTabs from "@theme/MimeTabs";
import ParamsItem from "@theme/ParamsItem";
import ResponseSamples from "@theme/ResponseSamples";
import SchemaItem from "@theme/SchemaItem";
import SchemaTabs from "@theme/SchemaTabs";
import Heading from "@theme/Heading";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Execute Fine-Tune Job"}
>
</Heading>

<MethodEndpoint
method={"post"}
path={"/api/2/auto_eval/modelfinetuneworker/executeFineTuneJob"}
>

</MethodEndpoint>



Execute a fine-tune job with the given parameters

<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
>
</Heading>

<MimeTabs
className={"openapi-tabs__mime"}
>
<TabItem
label={"application/json"}
value={"application/json-schema"}
>
<details
style={{}}
className={"openapi-markdown__details mime"}
data-collapsed={false}
open={true}
>
<summary
style={{}}
className={"openapi-markdown__details-summary-mime"}
>
<h3
className={"openapi-markdown__details-summary-header-body"}
>
Body
</h3>
</summary><div
style={{"textAlign":"left","marginLeft":"1rem"}}
>

</div><ul
style={{"marginLeft":"1rem"}}
>
<SchemaItem
collapsible={false}
name={"id"}
required={false}
schemaName={"string"}
qualifierMessage={undefined}
schema={{"type":"string"}}
>

</SchemaItem>
</ul>
</details>
</TabItem>
</MimeTabs><div>
<div>
<ApiTabs
label={undefined}
id={undefined}
>
<TabItem
label={"200"}
value={"200"}
>
<div>


Successful operation


</div><div>
<MimeTabs
className={"openapi-tabs__mime"}
schemaType={"response"}
>
<TabItem
label={"application/json"}
value={"application/json"}
>
<SchemaTabs
className={"openapi-tabs__schema"}
>
<TabItem
label={"Schema"}
value={"Schema"}
>
<details
style={{}}
className={"openapi-markdown__details response"}
data-collapsed={false}
open={true}
>
<summary
style={{}}
className={"openapi-markdown__details-summary-response"}
>
<strong>
Schema
</strong>
</summary><div
style={{"textAlign":"left","marginLeft":"1rem"}}
>

</div><ul
style={{"marginLeft":"1rem"}}
>
<SchemaItem
collapsible={false}
name={"id"}
required={false}
schemaName={"string"}
qualifierMessage={undefined}
schema={{"type":"string"}}
>

</SchemaItem><SchemaItem
collapsible={false}
name={"createdAt"}
required={false}
schemaName={"date-time"}
qualifierMessage={undefined}
schema={{"type":"string","format":"date-time"}}
>

</SchemaItem><SchemaItem
collapsible={false}
name={"updatedAt"}
required={false}
schemaName={"date-time"}
qualifierMessage={undefined}
schema={{"type":"string","format":"date-time"}}
>

</SchemaItem><SchemaItem
collapsible={false}
name={"creatorId"}
required={false}
schemaName={"string"}
qualifierMessage={undefined}
schema={{"type":"string"}}
>

</SchemaItem><SchemaItem
collapsible={false}
name={"status"}
required={false}
schemaName={"string"}
qualifierMessage={undefined}
schema={{"type":"string"}}
>

</SchemaItem><SchemaItem
collapsible={false}
name={"organizationId"}
required={false}
schemaName={["string","null"]}
qualifierMessage={undefined}
schema={{"type":["string","null"]}}
>

</SchemaItem><SchemaItem
collapsible={false}
name={"visibility"}
required={false}
schemaName={"string"}
qualifierMessage={"**Possible values:** [`PRIVATE`, `MEMBER`]"}
schema={{"type":"string","enum":["PRIVATE","MEMBER"]}}
>

</SchemaItem>
</ul>
</details>
</TabItem><TabItem
label={"Example (from schema)"}
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"executeFineTuneJob-exampleid\",\n \"createdAt\": \"2023-06-07T10:00:00Z\",\n \"updatedAt\": \"2023-06-07T10:05:00Z\",\n \"creatorId\": \"user-789012\",\n \"status\": \"COMPLETED\",\n \"organizationId\": \"org-345678\",\n \"visibility\": \"PRIVATE\"\n}"}
language={"json"}
>

</ResponseSamples>
</TabItem>
</SchemaTabs>
</TabItem>
</MimeTabs>
</div>
</TabItem>
</ApiTabs>
</div>
</div>

14 changes: 14 additions & 0 deletions website/docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: api-index
title: API Reference
sidebar_label: API Reference
---

# API Reference

Welcome to the API reference documentation.

<!-- ## Endpoints -->

- [Execute Fine-Tune Job](./execute-fine-tune-job)
- [List Metric Bases](./list-metric-bases)
82 changes: 82 additions & 0 deletions website/docs/api/lastmile-ai-api-v-2.info.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
id: lastmile-ai-api-v-2
title: "LastMile AI API V2"
description: "LastMile AI API V2: Components"
sidebar_label: Introduction
sidebar_position: 0
hide_title: true
custom_edit_url: null
---

import ApiLogo from "@theme/ApiLogo";
import Heading from "@theme/Heading";
import SchemaTabs from "@theme/SchemaTabs";
import TabItem from "@theme/TabItem";
import Export from "@theme/ApiExplorer/Export";

<span
className={"theme-doc-version-badge badge badge--secondary"}
children={"Version: 2.0"}
>
</span>

<Heading
as={"h1"}
className={"openapi__heading"}
children={"LastMile AI API V2"}
>
</Heading>



LastMile AI API V2: Components

<div
style={{"marginBottom":"2rem"}}
>
<Heading
id={"authentication"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Authentication"}
>
</Heading><SchemaTabs
className={"openapi-tabs__security-schemes"}
>
<TabItem
label={"HTTP: Bearer Auth"}
value={"Bearer"}
>




<div>
<table>
<tbody>
<tr>
<th>
Security Scheme Type:
</th><td>
http
</td>
</tr><tr>
<th>
HTTP Authorization Scheme:
</th><td>
bearer
</td>
</tr><tr>
<th>
Bearer format:
</th><td>
JWT
</td>
</tr>
</tbody>
</table>
</div>
</TabItem>
</SchemaTabs>
</div>

Loading

0 comments on commit 23b3783

Please sign in to comment.