Skip to content

Commit 143a17c

Browse files
committed
Added OpenAPI
1 parent 3ff1a50 commit 143a17c

File tree

7 files changed

+2504
-176
lines changed

7 files changed

+2504
-176
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@radix-ui/react-hover-card": "^1.1.1",
2020
"@radix-ui/react-select": "^2.0.0",
2121
"@radix-ui/react-slot": "^1.0.2",
22+
"@stoplight/elements": "^8.4.3",
2223
"@tailwindcss/typography": "^0.5.7",
2324
"@types/node": "20.4.9",
2425
"@types/react": "18.2.20",

pnpm-lock.yaml

Lines changed: 2163 additions & 168 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Sourcegraph
4+
version: Latest
5+
tags: []
6+
paths:
7+
/.api/cody/context:
8+
post:
9+
operationId: CodyService_context
10+
summary: Find relevant source locations given a natural language query
11+
description: |-
12+
Returns a list of source code locations (aka. "context") that are relevant
13+
to the given natural language query and list of repos.
14+
parameters: []
15+
responses:
16+
'200':
17+
description: The request has succeeded.
18+
content:
19+
application/json:
20+
schema:
21+
$ref: '#/components/schemas/CodyContextResponse'
22+
requestBody:
23+
required: true
24+
content:
25+
application/json:
26+
schema:
27+
$ref: '#/components/schemas/CodyContextRequest'
28+
/.api/llm/models:
29+
get:
30+
operationId: OAIModels_list
31+
description: Lists the currently available models, and provides basic information about each one such as the owner and availability.
32+
parameters: []
33+
responses:
34+
'200':
35+
description: The request has succeeded.
36+
content:
37+
application/json:
38+
schema:
39+
$ref: '#/components/schemas/OAIListModelsResponse'
40+
default:
41+
description: An unexpected error response.
42+
content:
43+
application/json:
44+
schema:
45+
$ref: '#/components/schemas/Error'
46+
/.api/llm/models/{modelId}:
47+
get:
48+
operationId: OAIModels_retrieveModel
49+
description: Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
50+
parameters:
51+
- name: modelId
52+
in: path
53+
required: true
54+
schema:
55+
type: string
56+
responses:
57+
'200':
58+
description: The request has succeeded.
59+
content:
60+
application/json:
61+
schema:
62+
$ref: '#/components/schemas/OAIModel'
63+
default:
64+
description: An unexpected error response.
65+
content:
66+
application/json:
67+
schema:
68+
$ref: '#/components/schemas/Error'
69+
components:
70+
schemas:
71+
BlobInfo:
72+
type: object
73+
required:
74+
- path
75+
- repository
76+
- commit
77+
- url
78+
properties:
79+
path:
80+
type: string
81+
repository:
82+
$ref: '#/components/schemas/RepositoryInfo'
83+
commit:
84+
$ref: '#/components/schemas/CommitInfo'
85+
url:
86+
type: string
87+
CodyContextRequest:
88+
type: object
89+
required:
90+
- query
91+
properties:
92+
repos:
93+
type: array
94+
items:
95+
$ref: '#/components/schemas/RepoSpec'
96+
description: The list of repos to search through.
97+
query:
98+
type: string
99+
description: The natural language query to find relevant context from the provided list of repos.
100+
codeResultsCount:
101+
type: integer
102+
format: int32
103+
minimum: 0
104+
maximum: 100
105+
description: 'The number of results to return from source code (example: Python or TypeScript).'
106+
default: 15
107+
textResultsCount:
108+
type: integer
109+
format: int32
110+
minimum: 0
111+
maximum: 100
112+
description: The number of results to return from text sources like Markdown.
113+
default: 5
114+
CodyContextResponse:
115+
type: object
116+
required:
117+
- results
118+
properties:
119+
results:
120+
type: array
121+
items:
122+
$ref: '#/components/schemas/FileChunkContext'
123+
CommitInfo:
124+
type: object
125+
required:
126+
- oid
127+
properties:
128+
oid:
129+
type: string
130+
Error:
131+
type: object
132+
required:
133+
- type
134+
- message
135+
properties:
136+
type:
137+
type: string
138+
message:
139+
type: string
140+
FileChunkContext:
141+
type: object
142+
required:
143+
- blob
144+
- startLine
145+
- endLine
146+
- chunkContent
147+
properties:
148+
blob:
149+
$ref: '#/components/schemas/BlobInfo'
150+
startLine:
151+
type: integer
152+
format: int32
153+
endLine:
154+
type: integer
155+
format: int32
156+
chunkContent:
157+
type: string
158+
OAIListModelsResponse:
159+
type: object
160+
required:
161+
- object
162+
- data
163+
properties:
164+
object:
165+
type: string
166+
enum:
167+
- list
168+
data:
169+
type: array
170+
items:
171+
$ref: '#/components/schemas/OAIModel'
172+
OAIModel:
173+
type: object
174+
required:
175+
- id
176+
- object
177+
- created
178+
- owned_by
179+
properties:
180+
id:
181+
type: string
182+
description: The model identifier, which can be referenced in the API endpoints.
183+
object:
184+
type: string
185+
enum:
186+
- model
187+
description: The object type, which is always "model".
188+
created:
189+
type: integer
190+
format: int64
191+
description: The Unix timestamp (in seconds) when the model was created.
192+
owned_by:
193+
type: string
194+
description: The organization that owns the model.
195+
description: Describes an OpenAI model offering that can be used with the API.
196+
RepoSpec:
197+
type: object
198+
properties:
199+
name:
200+
type: string
201+
description: The name of the repository.
202+
id:
203+
type: string
204+
description: The ID of the repository.
205+
description: |-
206+
RepoSpec matches a repository either by name or ID.
207+
208+
Exactly one of the properties must be defined. For example, the message
209+
`{id:"id", name:"name"}` is invalid because it declares both id and name.
210+
RepositoryInfo:
211+
type: object
212+
required:
213+
- id
214+
- name
215+
properties:
216+
id:
217+
type: string
218+
name:
219+
type: string
220+
Versions:
221+
type: string
222+
enum:
223+
- V5_7
224+
- V5_8
225+
- Latest

src/app/openapi/page.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use client"
2+
3+
import React from 'react';
4+
import Link from 'next/link'
5+
import { ArrowLeftIcon } from '@heroicons/react/20/solid';
6+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
7+
// @ts-ignore
8+
import { API } from '@stoplight/elements';
9+
import '@stoplight/elements/styles.min.css';
10+
11+
import './styles.css'
12+
13+
const OpenAPi = () => (
14+
<div className="App">
15+
<nav className='p-6 bg-white'>
16+
<Link href='/' className="!font-grotesk group inline-flex items-center text-sm text-gray-600 hover:text-gray-800 font-medium">
17+
<ArrowLeftIcon className="inline h-3 mr-2 transition-transform group-hover:-translate-x-1" /> Back to Docs
18+
</Link>
19+
</nav>
20+
<API
21+
apiDescriptionUrl="./openapi/openapi.Sourcegraph.Latest.yaml"
22+
router="hash"
23+
/>
24+
</div>
25+
)
26+
27+
export default OpenAPi

src/app/openapi/styles.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.sl-elements-api > .sl-flex:first-child {
2+
background-color: #ffffff;
3+
}
4+
5+
.sl-elements-api > .sl-flex:first-child * {
6+
background-color: #ffffff;
7+
}
8+
9+
.sl-elements-api .sl-my-3 {
10+
background-color: #ffffff;
11+
margin: 0px;
12+
padding: 12px;
13+
}
14+
15+
.TryItPanel .sl-panel__titlebar {
16+
background-color: #2D2B55;
17+
border-bottom-width: 0.1px;
18+
border-bottom-color: #6B7280;
19+
}
20+
21+
.TryItPanel .SendButtonHolder {
22+
border-top-width: 0.1px;
23+
border-top-color: #6B7280;
24+
padding-top: 10px;
25+
}
26+
27+
.TryItPanel .sl-button {
28+
background-color: #28a6bc;
29+
padding: 10px;
30+
height: 33px;
31+
border-radius: 4px;
32+
}
33+
34+
.TryItPanel .sl-button:hover {
35+
background-color: #19b7d2;
36+
}
37+
38+
.TryItPanel .TextRequestBody {
39+
background-color: #2D2B55;
40+
}
41+
42+
.TryItPanel {
43+
background-color: #2D2B55;
44+
}
45+
46+
.TryItPanel + .sl-panel > .sl-panel__titlebar {
47+
background-color: #2D2B55;
48+
margin-top: 10px;
49+
border-bottom-width: 0.1px;
50+
border-bottom-color: #6B7280;
51+
}
52+
53+
.TryItPanel + .sl-panel > .sl-panel__content-wrapper {
54+
background-color: #2D2B55;
55+
}
56+
57+
.sl-panel__titlebar {
58+
background-color: #E0E6F0;
59+
}
60+
61+
.sl-code-viewer__scroller {
62+
background-color: #EBEEF5;
63+
}
64+
65+
.TryItPanel + .sl-panel .sl-code-viewer__scroller {
66+
background-color: #2D2B55;
67+
}

src/components/Layout.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,27 @@ function Header() {
8888
export function Layout({ children }: { children: React.ReactNode }) {
8989
let pathname = usePathname();
9090
let isHomePage = pathname === '/';
91+
let isOpenApiPage = pathname === '/openapi';
9192

9293
return (
9394
<div className="flex w-full flex-col">
9495
<Header />
9596

9697
{isHomePage && <Hero />}
9798

98-
<div className="relative mx-auto flex w-full max-w-8xl flex-auto justify-center sm:px-2 lg:px-8 xl:px-12">
99-
<div className="hidden lg:relative lg:block lg:flex-none">
100-
<div className="absolute bottom-0 right-0 top-16 hidden h-12 w-px bg-transparent dark:block" />
101-
<div className="absolute bottom-0 right-0 top-28 hidden w-px bg-transparent dark:block" />
102-
<div className="sticky top-[4.75rem] -ml-0.5 h-[calc(100vh-4.75rem)] w-64 overflow-y-auto overflow-x-hidden py-16 pl-0.5 pr-8 xl:w-72 xl:pr-16">
103-
<Navigation />
99+
{!isOpenApiPage && (
100+
<div className="relative mx-auto flex w-full max-w-8xl flex-auto justify-center sm:px-2 lg:px-8 xl:px-12">
101+
<div className="hidden lg:relative lg:block lg:flex-none">
102+
<div className="absolute bottom-0 right-0 top-16 hidden h-12 w-px bg-transparent dark:block" />
103+
<div className="absolute bottom-0 right-0 top-28 hidden w-px bg-transparent dark:block" />
104+
<div className="sticky top-[4.75rem] -ml-0.5 h-[calc(100vh-4.75rem)] w-64 overflow-y-auto overflow-x-hidden py-16 pl-0.5 pr-8 xl:w-72 xl:pr-16">
105+
<Navigation />
106+
</div>
104107
</div>
108+
{children}
105109
</div>
106-
{children}
107-
</div>
110+
)}
111+
{isOpenApiPage && children}
108112
</div>
109113
);
110114
}

src/data/navigation.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,15 @@ export const navigation: NavigationItem[] = [
332332
},
333333
],
334334
},
335+
{
336+
separator: "Sourcegraph OPEN API",
337+
topics: [
338+
{
339+
title: "Sourcegraph Open API",
340+
href: "/openapi",
341+
}
342+
],
343+
},
335344
];
336345

337346
const navigation_5_2: NavigationItem[] = [

0 commit comments

Comments
 (0)