Skip to content

Commit

Permalink
feat(indexer): add openapi schema and ui (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Sep 15, 2023
1 parent 83857e1 commit 05a5bc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 64 deletions.
2 changes: 1 addition & 1 deletion packages/indexer/src/plugins/multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const FILE_UPLOAD_LIMIT = 20 * 1024 * 1024; // 20 MB
export default fp(async (fastify) => {
fastify.register(multipart, {
attachFieldsToBody: true,
sharedSchemaId: '#multipartField',
sharedSchemaId: 'multipartField',
limits: {
fileSize: FILE_UPLOAD_LIMIT,
files: 1,
Expand Down
60 changes: 0 additions & 60 deletions packages/indexer/src/plugins/schemas.ts

This file was deleted.

15 changes: 12 additions & 3 deletions packages/indexer/src/routes/indexes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface IndexFileOptionsField {
const root: FastifyPluginAsyncJsonSchemaToTs = async (fastify, _options): Promise<void> => {
fastify.post('/', {
schema: {
description: 'Create a new search index',
tags: ['indexes'],
body: {
type: 'object',
properties: {
Expand Down Expand Up @@ -43,6 +45,8 @@ const root: FastifyPluginAsyncJsonSchemaToTs = async (fastify, _options): Promis

fastify.delete('/:name', {
schema: {
description: 'Delete a search index',
tags: ['indexes'],
params: {
type: 'object',
properties: {
Expand Down Expand Up @@ -75,7 +79,9 @@ const root: FastifyPluginAsyncJsonSchemaToTs = async (fastify, _options): Promis

fastify.post('/:name/files', {
schema: {
// consumes: ['multipart/form-data'],
description: 'Upload a file for indexing',
tags: ['indexes'],
consumes: ['multipart/form-data'],
params: {
type: 'object',
properties: {
Expand All @@ -88,8 +94,9 @@ const root: FastifyPluginAsyncJsonSchemaToTs = async (fastify, _options): Promis
body: {
type: 'object',
properties: {
options: { $ref: '#multipartField' },
file: { $ref: '#multipartField' },
options: { $ref: 'multipartField' },
// TODO: missing proper file type from ajv plugin
file: { $ref: 'multipartField' },
},
required: ['file'],
},
Expand Down Expand Up @@ -150,6 +157,8 @@ const root: FastifyPluginAsyncJsonSchemaToTs = async (fastify, _options): Promis

fastify.delete('/:name/files/:filename', {
schema: {
description: 'Delete a file from the index',
tags: ['indexes'],
params: {
type: 'object',
properties: {
Expand Down

0 comments on commit 05a5bc4

Please sign in to comment.