From f495eb90da781ca1d064f99f9e006eb5fe73a199 Mon Sep 17 00:00:00 2001 From: kesleymartins-maga Date: Wed, 12 Nov 2025 16:01:49 -0300 Subject: [PATCH] MAG-00001 - feat: schema consulta post - run npm audit fix tinha algumas vulnerabilidades altas, ainda ficaram algumas 6 moderadas como pendente que necessitava executar audit fix --force - adicionado json schema de exemplo para consultas no modelo POST --- package-lock.json | 35 +++++----- src/content/docs/execucao/consultas.md | 91 ++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7b099e..731ebd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,11 @@ { - "name": "magazord-base-de-conhecimento", + "name": "@magazord/api-guidelines", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "magazord-base-de-conhecimento", - "version": "0.0.1", + "name": "@magazord/api-guidelines", "dependencies": { "@astrojs/check": "^0.5.9", "@astrojs/starlight": "^0.21.2", @@ -2751,9 +2750,9 @@ } }, "node_modules/astro": { - "version": "4.16.18", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.16.18.tgz", - "integrity": "sha512-G7zfwJt9BDHEZwlaLNvjbInIw2hPryyD654314KV/XT34pJU6SfN1S+mWa8RAkALcZNJnJXCJmT3JXLQStD3Lw==", + "version": "4.16.19", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.16.19.tgz", + "integrity": "sha512-baeSswPC5ZYvhGDoj25L2FuzKRWMgx105FetOPQVJFMCAp0o08OonYC7AhwsFdhvp7GapqjnC1Fe3lKb2lupYw==", "license": "MIT", "dependencies": { "@astrojs/compiler": "^2.10.3", @@ -4077,9 +4076,9 @@ } }, "node_modules/devalue": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.1.1.tgz", - "integrity": "sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.5.0.tgz", + "integrity": "sha512-69sM5yrHfFLJt0AZ9QqZXGCPfJ7fQjvpln3Rq5+PS03LD32Ost1Q9N+eEnaQwGRIriKkMImXD56ocjQmfjbV3w==", "license": "MIT" }, "node_modules/devlop": { @@ -7080,9 +7079,9 @@ } }, "node_modules/prebuild-install/node_modules/tar-fs": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.3.tgz", - "integrity": "sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", "license": "MIT", "dependencies": { "chownr": "^1.1.1", @@ -8666,9 +8665,9 @@ } }, "node_modules/tar-fs": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.0.tgz", - "integrity": "sha512-5Mty5y/sOF1YWj1J6GiBodjlDc05CUR8PKXrsnFAiSG0xA+GHeWLovaZPYUDXkH/1iKRf2+M5+OrRgzC7O9b7w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.1.tgz", + "integrity": "sha512-LZA0oaPOc2fVo82Txf3gw+AkEd38szODlptMYejQUhndHMLQ9M059uXR+AfS7DNo0NpINvSqDsvyaCrBVkptWg==", "license": "MIT", "dependencies": { "pump": "^3.0.0", @@ -9078,9 +9077,9 @@ } }, "node_modules/vite": { - "version": "5.4.19", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz", - "integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==", + "version": "5.4.21", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", + "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "license": "MIT", "dependencies": { "esbuild": "^0.21.3", diff --git a/src/content/docs/execucao/consultas.md b/src/content/docs/execucao/consultas.md index 2bd3a87..ed5c79a 100644 --- a/src/content/docs/execucao/consultas.md +++ b/src/content/docs/execucao/consultas.md @@ -172,14 +172,14 @@ A API **DEVE** *popular* os grupos de informações relacionados a outras entida Requsição GET -``` +```http GET /clients?select=name,email&populate=address HTTP/1.1 Accept: application/json ``` Requisição POST -``` +```http POST /clients/query HTTP/1.1 Accept: application/json @@ -191,7 +191,7 @@ Accept: application/json Resposta HTTP -``` +```json [{ "name": "Arthur", "email": "arthur@magazord.com.br", @@ -199,8 +199,89 @@ Resposta HTTP "id": 1, "city": "Rio do Sul", "state": "SC", - "country": "Brasil + "country": "Brasil" } }] -``` \ No newline at end of file +``` + +### Json Schema v7 +Schema de exemplo com suporte geral as configurações especificadas, modifique com base nas necessidades da implementação. + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "List Aplicativos", + "description": "Validação query de aplicativos.", + "type": "object", + "properties": { + "select": { + "type": "array", + "items": { + "type": "string", + "enum": [ + // ... Atributos da consulta + ] + } + }, + "omit": { + "type": "array", + "items": { + "type": "string", + "enum": [ + // ... Atributos da consulta + ] + } + }, + "filters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { + "type": "string", + "enum": [ + // ... Atributos da consulta + ] + "description": "Campos a consultado" + }, + "operator": { + "type": "string", + "enum": ["eq", "gt", "lt", "ne", "gte", "lte", "in", "like", "between"], + "description": "Comparador a ser utilizado" + }, + "value": { + "type": "string", + "description": "Valor utilizado no filtro" + } + }, + "required": ["field", "operator", "value"], + "additionalProperties": false + } + }, + "sorters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { + "type": "string", + "enum": [ + // ... Atributos da ordenação + ] + "description": "Campos a usado na ordenação" + }, + "direction": { + "type": "string", + "enum": ["ASC", "DESC"], + "description": "Direção da ordenação" + } + }, + "required": ["field", "direction"], + "additionalProperties": false + } + } + }, + "required": ["filters", "sorters", "select", "omit"] +} +```