The added/updated routes
import routing from '@novice1/routing';
import { OpenAPI } from '@novice1/api-doc-generator';
const router = routing().post(...);
const openapi = new OpenAPI();
const routes = openapi.add(router.getMeta());
const { path, method, schema } = routes[0];
Example:
import {
BasicAuthUtil
} from '@novice1/api-doc-generator';
const basicAuth = new BasicAuthUtil('basicAuth');
openapi.addDefaultSecurity(basicAuth);
Example:
openapi.addDefaultSecurity({
basicAuth: []
});
Example:
openapi.addDefaultSecurity({
basicAuth: []
});
Example:
openapi.addDefaultSecurity('basicAuth');
Example:
openapi.addResponse('200', {
"description": "A simple string response",
"content": {
"text/plain": {
"schema": {
"type": "string",
"example": "whoa!"
}
}
}
});
Example:
import {
ResponseUtil,
GroupResponseUtil
} from '@novice1/api-doc-generator';
const generalError = new ResponseUtil('GeneralError');
generalError
.setDescription('General Error')
.addMediaType('application/json', {
schema: {
$ref: '#/components/schemas/GeneralError'
}
});
const illegalInput = new ResponseUtil('IllegalInput');
illegalInput
.setDescription('Illegal input for operation.');
const responses = new GroupResponseUtil([
generalError,
illegalInput
]);
openapi.addResponse(responses);
// or
openapi
.addResponse(generalError)
.addResponse(illegalInput);
Example:
openapi
.addSecuritySchemes('basicAuth', {
type: 'http',
scheme: 'basic'
});
Example:
import {
BasicAuthUtil
} from '@novice1/api-doc-generator';
const basicAuth = new BasicAuthUtil('basicAuth');
openapi.addSecuritySchemes(basicAuth);
remove unused entities (possibly auto-generated) from components:
removed examples
removed headers
removed links
removed parameters
removed requestBodies
removed responses
removed schemas
removed securitySchemes
Optional
method: stringremove all routes
The removed routes
Example:
import {
BasicAuthUtil
} from '@novice1/api-doc-generator';
const basicAuth = new BasicAuthUtil('basicAuthName');
openapi.setDefaultSecurity(basicAuth);
Example:
openapi.setDefaultSecurity({
basicAuth: []
});
Example:
openapi.setDefaultSecurity('basicAuth');
Example:
import {
ResponseUtil,
GroupResponseUtil
} from '@novice1/api-doc-generator';
const generalError = new ResponseUtil('GeneralError');
generalError
.setDescription('General Error')
.addMediaType('application/json', {
schema: {
$ref: '#/components/schemas/GeneralError'
}
});
const responses = new GroupResponseUtil([
generalError,
// ... other responses
]);
openapi.setResponses(generalError);
// or
openapi.setResponses(responses);
Example:
openapi
.setSecuritySchemes({
basicAuth: {
type: 'http',
scheme: 'basic'
}
});
Example:
import {
BasicAuthUtil
} from '@novice1/api-doc-generator';
const basicAuth = new BasicAuthUtil('basicAuth');
openapi.setSecuritySchemes(basicAuth);
OpenAPI doc generator.
Note
For now it is not possible to only send files outside of object property (multipart). Well, at least not tried yet but it definitely doesn't work with alternatives.