Skip to main content

Types Configuration

If you'd like Genzy to be able to generate a detailed OpenAPI documentation, with SwaggerUI that includes Type Definitions, you can define types in a $genzy property.

If you're using TypeScript you can define configuration using TypeScript decorators.

note

If you're using decorators, make sure that you've set "experimentalDecorators" option to true in your tsconfig.json file.

const exampleTypeDefinition = {
$typeName: "Example",
$isArray: false,
name: "string",
age: "number"
};

const exampleArrayTypeDefinition = {
...exampleTypeDefinition,
$isArray: true,
};

class ExampleService {
$genzy = {
path: '/',
getAll: {
httpMethod: 'GET',
path: '/',
params: [
{ source: 'query', name: "pageNumber", type: 'string' },
{ source: 'query', name: "pageSize", type: 'string' },
],
result: exampleArrayTypeDefinition
},
getById: {
httpMethod: 'GET',
path: '/:id',
params: [
{ source: 'query', name: "includeDetails", type: 'boolean' }
{ source: 'path', name: 'id', type: 'string' },
],
result: exampleTypeDefinition
},
add: {
httpMethod: 'POST',
path: '/',
params: [
{ source: 'body', name: 'example', type: exampleTypeDefinition }
],
result: exampleTypeDefinition
},
update: {
httpMethod: 'PUT',
path: '/:id',
params: [
{ source: 'path', name: 'id', type: 'string' },
{ source: 'body', name: 'example', type: exampleTypeDefinition }
],
result: exampleTypeDefinition
},
delete: {
httpMethod: 'DELETE',
path: '/:id',
params: [
{ source: 'path', name: 'id', type: 'string' },
],
result: exampleTypeDefinition
},
}

async getAll(pageNumber, pageSize) {
return [];
}
async getById(includeDetails, id) {
return [];
}
async add(example) {
return example;
}
async update(id, example) {
return example;
}
async delete(id) {
return { id };
}
}
info

Types configuration is used at the server side, since it is used for telling Genzy how to set up a detailed OpenAPI documentation, with SwaggerUI that includes Type Definitions.