Skip to content

Commit

Permalink
fix: multipart references
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Sep 28, 2023
1 parent 0124226 commit f07f9ab
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/lib/utils/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,26 @@ function getParameters(
}
} else {
const requestBody = operation?.requestBody as OpenAPIV3.RequestBodyObject;
const schema = requestBody?.content['application/json']?.schema as OpenAPIV3.SchemaObject;
for (const [key, value] of Object.entries(schema?.properties ?? {})) {
const schemaJson = requestBody?.content['application/json']?.schema as OpenAPIV3.SchemaObject;
const schemaMultipart = requestBody?.content['multipart/form-data']?.schema as OpenAPIV3.SchemaObject;

// TODO: make this pretty
for (const [key, value] of Object.entries(schemaJson?.properties ?? {})) {
const property = value as AppwriteSchemaObject;
parameters.push({
name: key,
description: property.description ?? '',
required: schema?.required?.includes(key) ?? false,
required: schemaJson?.required?.includes(key) ?? false,
type: property.type ?? '',
example: property['x-example'] ?? ''
});
}
for (const [key, value] of Object.entries(schemaMultipart?.properties ?? {})) {
const property = value as AppwriteSchemaObject;
parameters.push({
name: key,
description: property.description ?? '',
required: schemaMultipart?.required?.includes(key) ?? false,
type: property.type ?? '',
example: property['x-example'] ?? ''
});
Expand Down

0 comments on commit f07f9ab

Please sign in to comment.