Skip to content

Commit

Permalink
Início dos testes usando o Redoc como gerador de documentação automát…
Browse files Browse the repository at this point in the history
…ica.
  • Loading branch information
leonelsanchesdasilva committed Nov 25, 2024
1 parent 4d6e3e1 commit 0a4e06a
Show file tree
Hide file tree
Showing 15 changed files with 654 additions and 1,112 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"no-prototype-builtins": "off",
"prettier/prettier": "off",
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-inferrable-types": "off"
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": "warn"
}
}
3 changes: 3 additions & 0 deletions infraestrutura/auto-documentacao/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Auto-documentação

Liquido utiliza a OpenAPI para documentação REST, versão 3.0.0. Todos os tipos e interfaces definidos aqui são utilizados para gerar um YAML que gera uma documentação OpenAPI. Os nomes das propriedades, portanto, serão em inglês.
13 changes: 13 additions & 0 deletions infraestrutura/auto-documentacao/documento-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InfoOpenApi } from "./info-open-api";
import { MetodoHttpOpenApi } from "./metodo-http-open-api";
import { RotaOpenApi } from "./rota-open-api";
import { ServerOpenApi } from "./server-open-api";
import { TagDocumentoOpenApi } from "./tag-documento-open-api";

export interface DocumentoOpenApi {
openapi: '3.0.0';
servers: ServerOpenApi[];
info: InfoOpenApi;
tags?: TagDocumentoOpenApi[];
paths?: {[key: string]: {[key in MetodoHttpOpenApi]?: RotaOpenApi}}
}
4 changes: 4 additions & 0 deletions infraestrutura/auto-documentacao/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './documento-open-api';
export * from './metodo-http-open-api';
export * from './rota-open-api';
export * from './server-open-api';
8 changes: 8 additions & 0 deletions infraestrutura/auto-documentacao/info-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { LicenseOpenApi } from "./license-open-api";

export interface InfoOpenApi {
description: string;
version: string;
title: string;
license: LicenseOpenApi;
}
4 changes: 4 additions & 0 deletions infraestrutura/auto-documentacao/license-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface LicenseOpenApi {
name: string;
url: string;
}
1 change: 1 addition & 0 deletions infraestrutura/auto-documentacao/metodo-http-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type MetodoHttpOpenApi = 'get' | 'post' | 'put' | 'delete' | 'patch';
5 changes: 5 additions & 0 deletions infraestrutura/auto-documentacao/response-content-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ResponseContentOpenApi {
type?: string
items?: any[]
schema?: any;
}
6 changes: 6 additions & 0 deletions infraestrutura/auto-documentacao/response-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ResponseContentOpenApi } from "./response-content-open-api";

export interface ResponseOpenApi {
description: string;
content?: {[key: string]: ResponseContentOpenApi}
}
9 changes: 9 additions & 0 deletions infraestrutura/auto-documentacao/rota-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ResponseOpenApi } from "./response-open-api";

export interface RotaOpenApi {
tags: string[];
summary: string;
description: string;
operationId: string;
responses: {[key: string]: ResponseOpenApi};
}
3 changes: 3 additions & 0 deletions infraestrutura/auto-documentacao/server-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ServerOpenApi {
url: string;
}
4 changes: 4 additions & 0 deletions infraestrutura/auto-documentacao/tag-documento-open-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface TagDocumentoOpenApi {
name: string;
description: string;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Configuração da aplicação em si.
liquido.arquetipo = 'rest'
liquido.nomeAplicacao = 'Minha aplicação'
liquido.aplicacaoVersao = '0.0.0'

// Configuração de arquivos estáticos
liquido.roteador.diretorioEstatico = 'publico'

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"prompts": "^2.4.2",
"redoc-express": "^2.1.0",
"xml2js": "^0.6.2",
"yargs": "^17.7.2"
},
Expand Down
Loading

0 comments on commit 0a4e06a

Please sign in to comment.