Add v1 routes to API and Swagger

This commit is contained in:
Tiago Yamamoto 2025-12-19 18:30:27 -03:00
parent 1309a120cb
commit 6cc02a7a8c
5 changed files with 1559 additions and 0 deletions

View file

@ -808,6 +808,60 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/companies": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Lista empresas",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Company"
}
}
}
}
},
"post": {
"description": "Cadastra farmácia, distribuidora ou administrador com CNPJ e licença sanitária.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Registro de empresas",
"parameters": [
{
"description": "Dados da empresa",
"name": "company",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.registerCompanyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.Company"
}
}
}
}
},
"/api/v1/companies/me": { "/api/v1/companies/me": {
"get": { "get": {
"security": [ "security": [
@ -832,6 +886,137 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/companies/{id}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Obter empresa",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Company"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"delete": {
"tags": [
"Empresas"
],
"summary": "Remover empresa",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Atualizar empresa",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Campos para atualização",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.updateCompanyRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Company"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/companies/{id}/rating": { "/api/v1/companies/{id}/rating": {
"get": { "get": {
"produces": [ "produces": [
@ -1028,6 +1213,215 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/orders": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Listar pedidos",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Order"
}
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Criação de pedido com split",
"parameters": [
{
"description": "Pedido",
"name": "order",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.createOrderRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.Order"
}
}
}
}
},
"/api/v1/orders/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Consulta pedido",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Order"
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"tags": [
"Pedidos"
],
"summary": "Remover pedido",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/orders/{id}/payment": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"produces": [
"application/json"
],
"tags": [
"Pagamentos"
],
"summary": "Cria preferência de pagamento Mercado Pago com split nativo",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.PaymentPreference"
}
}
}
}
},
"/api/v1/orders/{id}/status": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Atualiza status do pedido",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Novo status",
"name": "status",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.updateStatusRequest"
}
}
],
"responses": {
"204": {
"description": ""
}
}
}
},
"/api/v1/payments/webhook": { "/api/v1/payments/webhook": {
"post": { "post": {
"consumes": [ "consumes": [
@ -1061,6 +1455,190 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/products": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Lista catálogo com lote e validade",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Product"
}
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Cadastro de produto com rastreabilidade de lote",
"parameters": [
{
"description": "Produto",
"name": "product",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.registerProductRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.Product"
}
}
}
}
},
"/api/v1/products/{id}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Obter produto",
"parameters": [
{
"type": "string",
"description": "Product ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Product"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"delete": {
"tags": [
"Produtos"
],
"summary": "Remover produto",
"parameters": [
{
"type": "string",
"description": "Product ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Atualizar produto",
"parameters": [
{
"type": "string",
"description": "Product ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Campos para atualização",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.updateProductRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Product"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/reviews": { "/api/v1/reviews": {
"post": { "post": {
"security": [ "security": [

View file

@ -804,6 +804,60 @@
} }
} }
}, },
"/api/v1/companies": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Lista empresas",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Company"
}
}
}
}
},
"post": {
"description": "Cadastra farmácia, distribuidora ou administrador com CNPJ e licença sanitária.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Registro de empresas",
"parameters": [
{
"description": "Dados da empresa",
"name": "company",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.registerCompanyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.Company"
}
}
}
}
},
"/api/v1/companies/me": { "/api/v1/companies/me": {
"get": { "get": {
"security": [ "security": [
@ -828,6 +882,137 @@
} }
} }
}, },
"/api/v1/companies/{id}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Obter empresa",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Company"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"delete": {
"tags": [
"Empresas"
],
"summary": "Remover empresa",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Empresas"
],
"summary": "Atualizar empresa",
"parameters": [
{
"type": "string",
"description": "Company ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Campos para atualização",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.updateCompanyRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Company"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/companies/{id}/rating": { "/api/v1/companies/{id}/rating": {
"get": { "get": {
"produces": [ "produces": [
@ -1024,6 +1209,215 @@
} }
} }
}, },
"/api/v1/orders": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Listar pedidos",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Order"
}
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Criação de pedido com split",
"parameters": [
{
"description": "Pedido",
"name": "order",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.createOrderRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.Order"
}
}
}
}
},
"/api/v1/orders/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Consulta pedido",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Order"
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"tags": [
"Pedidos"
],
"summary": "Remover pedido",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/orders/{id}/payment": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"produces": [
"application/json"
],
"tags": [
"Pagamentos"
],
"summary": "Cria preferência de pagamento Mercado Pago com split nativo",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.PaymentPreference"
}
}
}
}
},
"/api/v1/orders/{id}/status": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Pedidos"
],
"summary": "Atualiza status do pedido",
"parameters": [
{
"type": "string",
"description": "Order ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Novo status",
"name": "status",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.updateStatusRequest"
}
}
],
"responses": {
"204": {
"description": ""
}
}
}
},
"/api/v1/payments/webhook": { "/api/v1/payments/webhook": {
"post": { "post": {
"consumes": [ "consumes": [
@ -1057,6 +1451,190 @@
} }
} }
}, },
"/api/v1/products": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Lista catálogo com lote e validade",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Product"
}
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Cadastro de produto com rastreabilidade de lote",
"parameters": [
{
"description": "Produto",
"name": "product",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.registerProductRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/domain.Product"
}
}
}
}
},
"/api/v1/products/{id}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Obter produto",
"parameters": [
{
"type": "string",
"description": "Product ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Product"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"delete": {
"tags": [
"Produtos"
],
"summary": "Remover produto",
"parameters": [
{
"type": "string",
"description": "Product ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Produtos"
],
"summary": "Atualizar produto",
"parameters": [
{
"type": "string",
"description": "Product ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Campos para atualização",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.updateProductRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Product"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/reviews": { "/api/v1/reviews": {
"post": { "post": {
"security": [ "security": [

View file

@ -1024,6 +1024,128 @@ paths:
summary: Remover item do carrinho summary: Remover item do carrinho
tags: tags:
- Carrinho - Carrinho
/api/v1/companies:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.Company'
type: array
summary: Lista empresas
tags:
- Empresas
post:
consumes:
- application/json
description: Cadastra farmácia, distribuidora ou administrador com CNPJ e licença
sanitária.
parameters:
- description: Dados da empresa
in: body
name: company
required: true
schema:
$ref: '#/definitions/handler.registerCompanyRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/domain.Company'
summary: Registro de empresas
tags:
- Empresas
/api/v1/companies/{id}:
delete:
parameters:
- description: Company ID
in: path
name: id
required: true
type: string
responses:
"204":
description: ""
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
summary: Remover empresa
tags:
- Empresas
get:
parameters:
- description: Company ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Company'
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
summary: Obter empresa
tags:
- Empresas
patch:
consumes:
- application/json
parameters:
- description: Company ID
in: path
name: id
required: true
type: string
- description: Campos para atualização
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handler.updateCompanyRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Company'
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
summary: Atualizar empresa
tags:
- Empresas
/api/v1/companies/{id}/rating: /api/v1/companies/{id}/rating:
get: get:
parameters: parameters:
@ -1157,6 +1279,135 @@ paths:
summary: Ajustar estoque summary: Ajustar estoque
tags: tags:
- Estoque - Estoque
/api/v1/orders:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.Order'
type: array
security:
- BearerAuth: []
summary: Listar pedidos
tags:
- Pedidos
post:
consumes:
- application/json
parameters:
- description: Pedido
in: body
name: order
required: true
schema:
$ref: '#/definitions/handler.createOrderRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/domain.Order'
summary: Criação de pedido com split
tags:
- Pedidos
/api/v1/orders/{id}:
delete:
parameters:
- description: Order ID
in: path
name: id
required: true
type: string
responses:
"204":
description: ""
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
security:
- BearerAuth: []
summary: Remover pedido
tags:
- Pedidos
get:
parameters:
- description: Order ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Order'
security:
- BearerAuth: []
summary: Consulta pedido
tags:
- Pedidos
/api/v1/orders/{id}/payment:
post:
parameters:
- description: Order ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/domain.PaymentPreference'
security:
- BearerAuth: []
summary: Cria preferência de pagamento Mercado Pago com split nativo
tags:
- Pagamentos
/api/v1/orders/{id}/status:
patch:
consumes:
- application/json
parameters:
- description: Order ID
in: path
name: id
required: true
type: string
- description: Novo status
in: body
name: status
required: true
schema:
$ref: '#/definitions/handler.updateStatusRequest'
produces:
- application/json
responses:
"204":
description: ""
security:
- BearerAuth: []
summary: Atualiza status do pedido
tags:
- Pedidos
/api/v1/payments/webhook: /api/v1/payments/webhook:
post: post:
consumes: consumes:
@ -1178,6 +1429,126 @@ paths:
summary: Recebe notificações do Mercado Pago summary: Recebe notificações do Mercado Pago
tags: tags:
- Pagamentos - Pagamentos
/api/v1/products:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.Product'
type: array
summary: Lista catálogo com lote e validade
tags:
- Produtos
post:
consumes:
- application/json
parameters:
- description: Produto
in: body
name: product
required: true
schema:
$ref: '#/definitions/handler.registerProductRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/domain.Product'
summary: Cadastro de produto com rastreabilidade de lote
tags:
- Produtos
/api/v1/products/{id}:
delete:
parameters:
- description: Product ID
in: path
name: id
required: true
type: string
responses:
"204":
description: ""
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
summary: Remover produto
tags:
- Produtos
get:
parameters:
- description: Product ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Product'
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
summary: Obter produto
tags:
- Produtos
patch:
consumes:
- application/json
parameters:
- description: Product ID
in: path
name: id
required: true
type: string
- description: Campos para atualização
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handler.updateProductRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Product'
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"404":
description: Not Found
schema:
additionalProperties:
type: string
type: object
summary: Atualizar produto
tags:
- Produtos
/api/v1/reviews: /api/v1/reviews:
post: post:
consumes: consumes:

View file

@ -123,6 +123,7 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
// @Param company body registerCompanyRequest true "Dados da empresa" // @Param company body registerCompanyRequest true "Dados da empresa"
// @Success 201 {object} domain.Company // @Success 201 {object} domain.Company
// @Router /api/companies [post] // @Router /api/companies [post]
// @Router /api/v1/companies [post]
func (h *Handler) CreateCompany(w http.ResponseWriter, r *http.Request) { func (h *Handler) CreateCompany(w http.ResponseWriter, r *http.Request) {
var req registerCompanyRequest var req registerCompanyRequest
if err := decodeJSON(r.Context(), r, &req); err != nil { if err := decodeJSON(r.Context(), r, &req); err != nil {
@ -151,6 +152,7 @@ func (h *Handler) CreateCompany(w http.ResponseWriter, r *http.Request) {
// @Produce json // @Produce json
// @Success 200 {array} domain.Company // @Success 200 {array} domain.Company
// @Router /api/companies [get] // @Router /api/companies [get]
// @Router /api/v1/companies [get]
func (h *Handler) ListCompanies(w http.ResponseWriter, r *http.Request) { func (h *Handler) ListCompanies(w http.ResponseWriter, r *http.Request) {
companies, err := h.svc.ListCompanies(r.Context()) companies, err := h.svc.ListCompanies(r.Context())
if err != nil { if err != nil {
@ -168,6 +170,7 @@ func (h *Handler) ListCompanies(w http.ResponseWriter, r *http.Request) {
// @Success 200 {object} domain.Company // @Success 200 {object} domain.Company
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/companies/{id} [get] // @Router /api/companies/{id} [get]
// @Router /api/v1/companies/{id} [get]
func (h *Handler) GetCompany(w http.ResponseWriter, r *http.Request) { func (h *Handler) GetCompany(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -195,6 +198,7 @@ func (h *Handler) GetCompany(w http.ResponseWriter, r *http.Request) {
// @Failure 400 {object} map[string]string // @Failure 400 {object} map[string]string
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/companies/{id} [patch] // @Router /api/companies/{id} [patch]
// @Router /api/v1/companies/{id} [patch]
func (h *Handler) UpdateCompany(w http.ResponseWriter, r *http.Request) { func (h *Handler) UpdateCompany(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -246,6 +250,7 @@ func (h *Handler) UpdateCompany(w http.ResponseWriter, r *http.Request) {
// @Failure 400 {object} map[string]string // @Failure 400 {object} map[string]string
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/companies/{id} [delete] // @Router /api/companies/{id} [delete]
// @Router /api/v1/companies/{id} [delete]
func (h *Handler) DeleteCompany(w http.ResponseWriter, r *http.Request) { func (h *Handler) DeleteCompany(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -351,6 +356,7 @@ func (h *Handler) GetCompanyRating(w http.ResponseWriter, r *http.Request) {
// @Param product body registerProductRequest true "Produto" // @Param product body registerProductRequest true "Produto"
// @Success 201 {object} domain.Product // @Success 201 {object} domain.Product
// @Router /api/products [post] // @Router /api/products [post]
// @Router /api/v1/products [post]
func (h *Handler) CreateProduct(w http.ResponseWriter, r *http.Request) { func (h *Handler) CreateProduct(w http.ResponseWriter, r *http.Request) {
var req registerProductRequest var req registerProductRequest
if err := decodeJSON(r.Context(), r, &req); err != nil { if err := decodeJSON(r.Context(), r, &req); err != nil {
@ -382,6 +388,7 @@ func (h *Handler) CreateProduct(w http.ResponseWriter, r *http.Request) {
// @Produce json // @Produce json
// @Success 200 {array} domain.Product // @Success 200 {array} domain.Product
// @Router /api/products [get] // @Router /api/products [get]
// @Router /api/v1/products [get]
func (h *Handler) ListProducts(w http.ResponseWriter, r *http.Request) { func (h *Handler) ListProducts(w http.ResponseWriter, r *http.Request) {
products, err := h.svc.ListProducts(r.Context()) products, err := h.svc.ListProducts(r.Context())
if err != nil { if err != nil {
@ -399,6 +406,7 @@ func (h *Handler) ListProducts(w http.ResponseWriter, r *http.Request) {
// @Success 200 {object} domain.Product // @Success 200 {object} domain.Product
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/products/{id} [get] // @Router /api/products/{id} [get]
// @Router /api/v1/products/{id} [get]
func (h *Handler) GetProduct(w http.ResponseWriter, r *http.Request) { func (h *Handler) GetProduct(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -426,6 +434,7 @@ func (h *Handler) GetProduct(w http.ResponseWriter, r *http.Request) {
// @Failure 400 {object} map[string]string // @Failure 400 {object} map[string]string
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/products/{id} [patch] // @Router /api/products/{id} [patch]
// @Router /api/v1/products/{id} [patch]
func (h *Handler) UpdateProduct(w http.ResponseWriter, r *http.Request) { func (h *Handler) UpdateProduct(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -483,6 +492,7 @@ func (h *Handler) UpdateProduct(w http.ResponseWriter, r *http.Request) {
// @Failure 400 {object} map[string]string // @Failure 400 {object} map[string]string
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/products/{id} [delete] // @Router /api/products/{id} [delete]
// @Router /api/v1/products/{id} [delete]
func (h *Handler) DeleteProduct(w http.ResponseWriter, r *http.Request) { func (h *Handler) DeleteProduct(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -568,6 +578,7 @@ func (h *Handler) AdjustInventory(w http.ResponseWriter, r *http.Request) {
// @Param order body createOrderRequest true "Pedido" // @Param order body createOrderRequest true "Pedido"
// @Success 201 {object} domain.Order // @Success 201 {object} domain.Order
// @Router /api/orders [post] // @Router /api/orders [post]
// @Router /api/v1/orders [post]
func (h *Handler) CreateOrder(w http.ResponseWriter, r *http.Request) { func (h *Handler) CreateOrder(w http.ResponseWriter, r *http.Request) {
var req createOrderRequest var req createOrderRequest
if err := decodeJSON(r.Context(), r, &req); err != nil { if err := decodeJSON(r.Context(), r, &req); err != nil {
@ -603,6 +614,7 @@ func (h *Handler) CreateOrder(w http.ResponseWriter, r *http.Request) {
// @Produce json // @Produce json
// @Success 200 {array} domain.Order // @Success 200 {array} domain.Order
// @Router /api/orders [get] // @Router /api/orders [get]
// @Router /api/v1/orders [get]
func (h *Handler) ListOrders(w http.ResponseWriter, r *http.Request) { func (h *Handler) ListOrders(w http.ResponseWriter, r *http.Request) {
orders, err := h.svc.ListOrders(r.Context()) orders, err := h.svc.ListOrders(r.Context())
if err != nil { if err != nil {
@ -621,6 +633,7 @@ func (h *Handler) ListOrders(w http.ResponseWriter, r *http.Request) {
// @Param id path string true "Order ID" // @Param id path string true "Order ID"
// @Success 200 {object} domain.Order // @Success 200 {object} domain.Order
// @Router /api/orders/{id} [get] // @Router /api/orders/{id} [get]
// @Router /api/v1/orders/{id} [get]
func (h *Handler) GetOrder(w http.ResponseWriter, r *http.Request) { func (h *Handler) GetOrder(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -647,6 +660,7 @@ func (h *Handler) GetOrder(w http.ResponseWriter, r *http.Request) {
// @Param status body updateStatusRequest true "Novo status" // @Param status body updateStatusRequest true "Novo status"
// @Success 204 "" // @Success 204 ""
// @Router /api/orders/{id}/status [patch] // @Router /api/orders/{id}/status [patch]
// @Router /api/v1/orders/{id}/status [patch]
func (h *Handler) UpdateOrderStatus(w http.ResponseWriter, r *http.Request) { func (h *Handler) UpdateOrderStatus(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -682,6 +696,7 @@ func (h *Handler) UpdateOrderStatus(w http.ResponseWriter, r *http.Request) {
// @Failure 400 {object} map[string]string // @Failure 400 {object} map[string]string
// @Failure 404 {object} map[string]string // @Failure 404 {object} map[string]string
// @Router /api/orders/{id} [delete] // @Router /api/orders/{id} [delete]
// @Router /api/v1/orders/{id} [delete]
func (h *Handler) DeleteOrder(w http.ResponseWriter, r *http.Request) { func (h *Handler) DeleteOrder(w http.ResponseWriter, r *http.Request) {
id, err := parseUUIDFromPath(r.URL.Path) id, err := parseUUIDFromPath(r.URL.Path)
if err != nil { if err != nil {
@ -825,6 +840,7 @@ func (h *Handler) DeleteCartItem(w http.ResponseWriter, r *http.Request) {
// @Param id path string true "Order ID" // @Param id path string true "Order ID"
// @Success 201 {object} domain.PaymentPreference // @Success 201 {object} domain.PaymentPreference
// @Router /api/orders/{id}/payment [post] // @Router /api/orders/{id}/payment [post]
// @Router /api/v1/orders/{id}/payment [post]
func (h *Handler) CreatePaymentPreference(w http.ResponseWriter, r *http.Request) { func (h *Handler) CreatePaymentPreference(w http.ResponseWriter, r *http.Request) {
if !strings.HasSuffix(r.URL.Path, "/payment") { if !strings.HasSuffix(r.URL.Path, "/payment") {
http.NotFound(w, r) http.NotFound(w, r)

View file

@ -67,6 +67,11 @@ func New(cfg config.Config) (*Server, error) {
mux.Handle("GET /api/companies/", chain(http.HandlerFunc(h.GetCompany), middleware.Logger, middleware.Gzip)) mux.Handle("GET /api/companies/", chain(http.HandlerFunc(h.GetCompany), middleware.Logger, middleware.Gzip))
mux.Handle("PATCH /api/companies/", chain(http.HandlerFunc(h.UpdateCompany), middleware.Logger, middleware.Gzip)) mux.Handle("PATCH /api/companies/", chain(http.HandlerFunc(h.UpdateCompany), middleware.Logger, middleware.Gzip))
mux.Handle("DELETE /api/companies/", chain(http.HandlerFunc(h.DeleteCompany), middleware.Logger, middleware.Gzip)) mux.Handle("DELETE /api/companies/", chain(http.HandlerFunc(h.DeleteCompany), middleware.Logger, middleware.Gzip))
mux.Handle("POST /api/v1/companies", chain(http.HandlerFunc(h.CreateCompany), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/companies", chain(http.HandlerFunc(h.ListCompanies), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/companies/", chain(http.HandlerFunc(h.GetCompany), middleware.Logger, middleware.Gzip))
mux.Handle("PATCH /api/v1/companies/", chain(http.HandlerFunc(h.UpdateCompany), middleware.Logger, middleware.Gzip))
mux.Handle("DELETE /api/v1/companies/", chain(http.HandlerFunc(h.DeleteCompany), middleware.Logger, middleware.Gzip))
mux.Handle("PATCH /api/v1/companies/", chain(http.HandlerFunc(h.VerifyCompany), middleware.Logger, middleware.Gzip, adminOnly)) mux.Handle("PATCH /api/v1/companies/", chain(http.HandlerFunc(h.VerifyCompany), middleware.Logger, middleware.Gzip, adminOnly))
mux.Handle("GET /api/v1/companies/me", chain(http.HandlerFunc(h.GetMyCompany), middleware.Logger, middleware.Gzip, auth)) mux.Handle("GET /api/v1/companies/me", chain(http.HandlerFunc(h.GetMyCompany), middleware.Logger, middleware.Gzip, auth))
mux.Handle("GET /api/v1/companies/", chain(http.HandlerFunc(h.GetCompanyRating), middleware.Logger, middleware.Gzip)) mux.Handle("GET /api/v1/companies/", chain(http.HandlerFunc(h.GetCompanyRating), middleware.Logger, middleware.Gzip))
@ -76,6 +81,11 @@ func New(cfg config.Config) (*Server, error) {
mux.Handle("GET /api/products/", chain(http.HandlerFunc(h.GetProduct), middleware.Logger, middleware.Gzip)) mux.Handle("GET /api/products/", chain(http.HandlerFunc(h.GetProduct), middleware.Logger, middleware.Gzip))
mux.Handle("PATCH /api/products/", chain(http.HandlerFunc(h.UpdateProduct), middleware.Logger, middleware.Gzip)) mux.Handle("PATCH /api/products/", chain(http.HandlerFunc(h.UpdateProduct), middleware.Logger, middleware.Gzip))
mux.Handle("DELETE /api/products/", chain(http.HandlerFunc(h.DeleteProduct), middleware.Logger, middleware.Gzip)) mux.Handle("DELETE /api/products/", chain(http.HandlerFunc(h.DeleteProduct), middleware.Logger, middleware.Gzip))
mux.Handle("POST /api/v1/products", chain(http.HandlerFunc(h.CreateProduct), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/products", chain(http.HandlerFunc(h.ListProducts), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/products/", chain(http.HandlerFunc(h.GetProduct), middleware.Logger, middleware.Gzip))
mux.Handle("PATCH /api/v1/products/", chain(http.HandlerFunc(h.UpdateProduct), middleware.Logger, middleware.Gzip))
mux.Handle("DELETE /api/v1/products/", chain(http.HandlerFunc(h.DeleteProduct), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/inventory", chain(http.HandlerFunc(h.ListInventory), middleware.Logger, middleware.Gzip, auth)) mux.Handle("GET /api/v1/inventory", chain(http.HandlerFunc(h.ListInventory), middleware.Logger, middleware.Gzip, auth))
mux.Handle("POST /api/v1/inventory/adjust", chain(http.HandlerFunc(h.AdjustInventory), middleware.Logger, middleware.Gzip, auth)) mux.Handle("POST /api/v1/inventory/adjust", chain(http.HandlerFunc(h.AdjustInventory), middleware.Logger, middleware.Gzip, auth))
@ -86,6 +96,12 @@ func New(cfg config.Config) (*Server, error) {
mux.Handle("PATCH /api/orders/", chain(http.HandlerFunc(h.UpdateOrderStatus), middleware.Logger, middleware.Gzip, auth)) mux.Handle("PATCH /api/orders/", chain(http.HandlerFunc(h.UpdateOrderStatus), middleware.Logger, middleware.Gzip, auth))
mux.Handle("DELETE /api/orders/", chain(http.HandlerFunc(h.DeleteOrder), middleware.Logger, middleware.Gzip, auth)) mux.Handle("DELETE /api/orders/", chain(http.HandlerFunc(h.DeleteOrder), middleware.Logger, middleware.Gzip, auth))
mux.Handle("POST /api/orders/", chain(http.HandlerFunc(h.CreatePaymentPreference), middleware.Logger, middleware.Gzip, auth)) mux.Handle("POST /api/orders/", chain(http.HandlerFunc(h.CreatePaymentPreference), middleware.Logger, middleware.Gzip, auth))
mux.Handle("POST /api/v1/orders", chain(http.HandlerFunc(h.CreateOrder), middleware.Logger, middleware.Gzip, auth))
mux.Handle("GET /api/v1/orders", chain(http.HandlerFunc(h.ListOrders), middleware.Logger, middleware.Gzip, auth))
mux.Handle("GET /api/v1/orders/", chain(http.HandlerFunc(h.GetOrder), middleware.Logger, middleware.Gzip, auth))
mux.Handle("PATCH /api/v1/orders/", chain(http.HandlerFunc(h.UpdateOrderStatus), middleware.Logger, middleware.Gzip, auth))
mux.Handle("DELETE /api/v1/orders/", chain(http.HandlerFunc(h.DeleteOrder), middleware.Logger, middleware.Gzip, auth))
mux.Handle("POST /api/v1/orders/", chain(http.HandlerFunc(h.CreatePaymentPreference), middleware.Logger, middleware.Gzip, auth))
mux.Handle("POST /api/v1/shipments", chain(http.HandlerFunc(h.CreateShipment), middleware.Logger, middleware.Gzip, auth)) mux.Handle("POST /api/v1/shipments", chain(http.HandlerFunc(h.CreateShipment), middleware.Logger, middleware.Gzip, auth))
mux.Handle("GET /api/v1/shipments/", chain(http.HandlerFunc(h.GetShipmentByOrderID), middleware.Logger, middleware.Gzip, auth)) mux.Handle("GET /api/v1/shipments/", chain(http.HandlerFunc(h.GetShipmentByOrderID), middleware.Logger, middleware.Gzip, auth))