From 0d1cd0aaaaaeb6521b1d5b33c2e687877d94d940 Mon Sep 17 00:00:00 2001 From: Pc Date: Mon, 8 Apr 2024 22:03:31 +0330 Subject: [PATCH] fix: Fix generate swagger open api separately for each microservice. --- Makefile | 6 +- .../services/identity_service/docs/docs.go | 363 ------------- .../identity_service/docs/swagger.json | 363 ------------- .../identity_service/docs/swagger.yaml | 228 -------- .../services/inventory_service/docs/docs.go | 127 +++++ .../inventory_service/docs/swagger.json | 99 ++++ .../inventory_service/docs/swagger.yaml | 62 +++ .../services/product_service/docs/docs.go | 82 --- .../product_service/docs/swagger.json | 82 --- .../product_service/docs/swagger.yaml | 52 -- services/product_service/docs/docs.go | 490 ++++++++++++++++++ services/product_service/docs/swagger.json | 462 +++++++++++++++++ services/product_service/docs/swagger.yaml | 290 +++++++++++ 13 files changed, 1533 insertions(+), 1173 deletions(-) create mode 100644 internal/services/inventory_service/docs/docs.go create mode 100644 internal/services/inventory_service/docs/swagger.json create mode 100644 internal/services/inventory_service/docs/swagger.yaml create mode 100644 services/product_service/docs/docs.go create mode 100644 services/product_service/docs/swagger.json create mode 100644 services/product_service/docs/swagger.yaml diff --git a/Makefile b/Makefile index 927a779..a7f5a03 100644 --- a/Makefile +++ b/Makefile @@ -43,12 +43,12 @@ proto_identities_get_user_by_id_service: swagger_products: @echo Starting swagger generating - swag init -g ./internal/services/product_service/cmd/main.go -o ./internal/services/product_service/docs + swag init -g ./internal/services/product_service/cmd/main.go -o ./internal/services/product_service/docs --exclude ./internal/services/identity_service, ./internal/services/inventory_service swagger_identities: @echo Starting swagger generating - swag init -g ./internal/services/identity_service/cmd/main.go -o ./internal/services/identity_service/docs + swag init -g ./internal/services/identity_service/cmd/main.go -o ./internal/services/identity_service/docs --exclude ./internal/services/product_service, ./internal/services/inventory_service swagger_inventories: @echo Starting swagger generating - swag init -g ./internal/services/inventory_service/cmd/main.go -o ./internal/services/inventory_service/docs \ No newline at end of file + swag init -g ./internal/services/inventory_service/cmd/main.go -o ./internal/services/inventory_service/docs --exclude ./internal/services/product_service, ./internal/services/identity_service \ No newline at end of file diff --git a/internal/services/identity_service/docs/docs.go b/internal/services/identity_service/docs/docs.go index 8e47450..e7ebed8 100644 --- a/internal/services/identity_service/docs/docs.go +++ b/internal/services/identity_service/docs/docs.go @@ -16,248 +16,6 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/api/v1/products": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Get all products", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Get all product", - "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dtos.GetProductsResponseDto" - } - } - } - }, - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Create new product item", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Create product", - "parameters": [ - { - "description": "Product data", - "name": "CreateProductRequestDto", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dtos.CreateProductRequestDto" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dtos.CreateProductResponseDto" - } - } - } - } - }, - "/api/v1/products/search": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Search products", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Search products", - "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "string", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dtos.SearchProductsResponseDto" - } - } - } - } - }, - "/api/v1/products/{id}": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Get product by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Get product", - "parameters": [ - { - "type": "string", - "description": "Product ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dtos.GetProductByIdResponseDto" - } - } - } - }, - "put": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Update existing product", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Update product", - "parameters": [ - { - "description": "Product data", - "name": "UpdateProductRequestDto", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dtos.UpdateProductRequestDto" - } - }, - { - "type": "string", - "description": "Product ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "" - } - } - }, - "delete": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Delete existing product", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Delete product", - "parameters": [ - { - "type": "string", - "description": "Product ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "" - } - } - } - }, "/api/v1/users": { "post": { "security": [ @@ -299,79 +57,6 @@ const docTemplate = `{ } }, "definitions": { - "dtos.CreateProductRequestDto": { - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "inventoryId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - } - } - }, - "dtos.CreateProductResponseDto": { - "type": "object", - "properties": { - "productId": { - "type": "string" - } - } - }, - "dtos.GetProductByIdResponseDto": { - "type": "object", - "properties": { - "product": { - "$ref": "#/definitions/dtos.ProductDto" - } - } - }, - "dtos.GetProductsResponseDto": { - "type": "object", - "properties": { - "products": { - "type": "object" - } - } - }, - "dtos.ProductDto": { - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "createdAt": { - "type": "string" - }, - "description": { - "type": "string" - }, - "inventoryId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - }, - "productId": { - "type": "string" - }, - "updatedAt": { - "type": "string" - } - } - }, "dtos.RegisterUserRequestDto": { "type": "object", "properties": { @@ -414,54 +99,6 @@ const docTemplate = `{ "type": "string" } } - }, - "dtos.SearchProductsResponseDto": { - "type": "object", - "properties": { - "products": { - "type": "object" - } - } - }, - "dtos.UpdateProductRequestDto": { - "type": "object", - "required": [ - "count", - "inventoryId", - "name", - "price" - ], - "properties": { - "count": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "inventoryId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - } - } - }, - "utils.FilterModel": { - "type": "object", - "properties": { - "comparison": { - "type": "string" - }, - "field": { - "type": "string" - }, - "value": { - "type": "string" - } - } } }, "securityDefinitions": { diff --git a/internal/services/identity_service/docs/swagger.json b/internal/services/identity_service/docs/swagger.json index d35df53..16b1cf0 100644 --- a/internal/services/identity_service/docs/swagger.json +++ b/internal/services/identity_service/docs/swagger.json @@ -4,248 +4,6 @@ "contact": {} }, "paths": { - "/api/v1/products": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Get all products", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Get all product", - "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dtos.GetProductsResponseDto" - } - } - } - }, - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Create new product item", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Create product", - "parameters": [ - { - "description": "Product data", - "name": "CreateProductRequestDto", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dtos.CreateProductRequestDto" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dtos.CreateProductResponseDto" - } - } - } - } - }, - "/api/v1/products/search": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Search products", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Search products", - "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "string", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dtos.SearchProductsResponseDto" - } - } - } - } - }, - "/api/v1/products/{id}": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Get product by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Get product", - "parameters": [ - { - "type": "string", - "description": "Product ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dtos.GetProductByIdResponseDto" - } - } - } - }, - "put": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Update existing product", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Update product", - "parameters": [ - { - "description": "Product data", - "name": "UpdateProductRequestDto", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dtos.UpdateProductRequestDto" - } - }, - { - "type": "string", - "description": "Product ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "" - } - } - }, - "delete": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Delete existing product", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Products" - ], - "summary": "Delete product", - "parameters": [ - { - "type": "string", - "description": "Product ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "" - } - } - } - }, "/api/v1/users": { "post": { "security": [ @@ -287,79 +45,6 @@ } }, "definitions": { - "dtos.CreateProductRequestDto": { - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "inventoryId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - } - } - }, - "dtos.CreateProductResponseDto": { - "type": "object", - "properties": { - "productId": { - "type": "string" - } - } - }, - "dtos.GetProductByIdResponseDto": { - "type": "object", - "properties": { - "product": { - "$ref": "#/definitions/dtos.ProductDto" - } - } - }, - "dtos.GetProductsResponseDto": { - "type": "object", - "properties": { - "products": { - "type": "object" - } - } - }, - "dtos.ProductDto": { - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "createdAt": { - "type": "string" - }, - "description": { - "type": "string" - }, - "inventoryId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - }, - "productId": { - "type": "string" - }, - "updatedAt": { - "type": "string" - } - } - }, "dtos.RegisterUserRequestDto": { "type": "object", "properties": { @@ -402,54 +87,6 @@ "type": "string" } } - }, - "dtos.SearchProductsResponseDto": { - "type": "object", - "properties": { - "products": { - "type": "object" - } - } - }, - "dtos.UpdateProductRequestDto": { - "type": "object", - "required": [ - "count", - "inventoryId", - "name", - "price" - ], - "properties": { - "count": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "inventoryId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - } - } - }, - "utils.FilterModel": { - "type": "object", - "properties": { - "comparison": { - "type": "string" - }, - "field": { - "type": "string" - }, - "value": { - "type": "string" - } - } } }, "securityDefinitions": { diff --git a/internal/services/identity_service/docs/swagger.yaml b/internal/services/identity_service/docs/swagger.yaml index fee6e97..2073332 100644 --- a/internal/services/identity_service/docs/swagger.yaml +++ b/internal/services/identity_service/docs/swagger.yaml @@ -1,51 +1,4 @@ definitions: - dtos.CreateProductRequestDto: - properties: - count: - type: integer - description: - type: string - inventoryId: - type: integer - name: - type: string - price: - type: number - type: object - dtos.CreateProductResponseDto: - properties: - productId: - type: string - type: object - dtos.GetProductByIdResponseDto: - properties: - product: - $ref: '#/definitions/dtos.ProductDto' - type: object - dtos.GetProductsResponseDto: - properties: - products: - type: object - type: object - dtos.ProductDto: - properties: - count: - type: integer - createdAt: - type: string - description: - type: string - inventoryId: - type: integer - name: - type: string - price: - type: number - productId: - type: string - updatedAt: - type: string - type: object dtos.RegisterUserRequestDto: properties: email: @@ -74,190 +27,9 @@ definitions: userName: type: string type: object - dtos.SearchProductsResponseDto: - properties: - products: - type: object - type: object - dtos.UpdateProductRequestDto: - properties: - count: - type: integer - description: - type: string - inventoryId: - type: integer - name: - type: string - price: - type: number - required: - - count - - inventoryId - - name - - price - type: object - utils.FilterModel: - properties: - comparison: - type: string - field: - type: string - value: - type: string - type: object info: contact: {} paths: - /api/v1/products: - get: - consumes: - - application/json - description: Get all products - parameters: - - in: query - name: orderBy - type: string - - in: query - name: page - type: integer - - in: query - name: size - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dtos.GetProductsResponseDto' - security: - - ApiKeyAuth: [] - summary: Get all product - tags: - - Products - post: - consumes: - - application/json - description: Create new product item - parameters: - - description: Product data - in: body - name: CreateProductRequestDto - required: true - schema: - $ref: '#/definitions/dtos.CreateProductRequestDto' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dtos.CreateProductResponseDto' - security: - - ApiKeyAuth: [] - summary: Create product - tags: - - Products - /api/v1/products/{id}: - delete: - consumes: - - application/json - description: Delete existing product - parameters: - - description: Product ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "204": - description: "" - security: - - ApiKeyAuth: [] - summary: Delete product - tags: - - Products - get: - consumes: - - application/json - description: Get product by id - parameters: - - description: Product ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dtos.GetProductByIdResponseDto' - security: - - ApiKeyAuth: [] - summary: Get product - tags: - - Products - put: - consumes: - - application/json - description: Update existing product - parameters: - - description: Product data - in: body - name: UpdateProductRequestDto - required: true - schema: - $ref: '#/definitions/dtos.UpdateProductRequestDto' - - description: Product ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "204": - description: "" - security: - - ApiKeyAuth: [] - summary: Update product - tags: - - Products - /api/v1/products/search: - get: - consumes: - - application/json - description: Search products - parameters: - - in: query - name: orderBy - type: string - - in: query - name: page - type: integer - - in: query - name: search - type: string - - in: query - name: size - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dtos.SearchProductsResponseDto' - security: - - ApiKeyAuth: [] - summary: Search products - tags: - - Products /api/v1/users: post: consumes: diff --git a/internal/services/inventory_service/docs/docs.go b/internal/services/inventory_service/docs/docs.go new file mode 100644 index 0000000..e7ebed8 --- /dev/null +++ b/internal/services/inventory_service/docs/docs.go @@ -0,0 +1,127 @@ +// Package docs GENERATED BY SWAG; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/v1/users": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Create new user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Register user", + "parameters": [ + { + "description": "User data", + "name": "RegisterUserRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.RegisterUserRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dtos.RegisterUserResponseDto" + } + } + } + } + } + }, + "definitions": { + "dtos.RegisterUserRequestDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, + "dtos.RegisterUserResponseDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userId": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/internal/services/inventory_service/docs/swagger.json b/internal/services/inventory_service/docs/swagger.json new file mode 100644 index 0000000..16b1cf0 --- /dev/null +++ b/internal/services/inventory_service/docs/swagger.json @@ -0,0 +1,99 @@ +{ + "swagger": "2.0", + "info": { + "contact": {} + }, + "paths": { + "/api/v1/users": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Create new user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Register user", + "parameters": [ + { + "description": "User data", + "name": "RegisterUserRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.RegisterUserRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dtos.RegisterUserResponseDto" + } + } + } + } + } + }, + "definitions": { + "dtos.RegisterUserRequestDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, + "dtos.RegisterUserResponseDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userId": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/internal/services/inventory_service/docs/swagger.yaml b/internal/services/inventory_service/docs/swagger.yaml new file mode 100644 index 0000000..2073332 --- /dev/null +++ b/internal/services/inventory_service/docs/swagger.yaml @@ -0,0 +1,62 @@ +definitions: + dtos.RegisterUserRequestDto: + properties: + email: + type: string + firstName: + type: string + lastName: + type: string + password: + type: string + userName: + type: string + type: object + dtos.RegisterUserResponseDto: + properties: + email: + type: string + firstName: + type: string + lastName: + type: string + password: + type: string + userId: + type: string + userName: + type: string + type: object +info: + contact: {} +paths: + /api/v1/users: + post: + consumes: + - application/json + description: Create new user + parameters: + - description: User data + in: body + name: RegisterUserRequestDto + required: true + schema: + $ref: '#/definitions/dtos.RegisterUserRequestDto' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dtos.RegisterUserResponseDto' + security: + - ApiKeyAuth: [] + summary: Register user + tags: + - Users +securityDefinitions: + ApiKeyAuth: + in: header + name: Authorization + type: apiKey +swagger: "2.0" diff --git a/internal/services/product_service/docs/docs.go b/internal/services/product_service/docs/docs.go index 8e47450..11a025d 100644 --- a/internal/services/product_service/docs/docs.go +++ b/internal/services/product_service/docs/docs.go @@ -257,45 +257,6 @@ const docTemplate = `{ } } } - }, - "/api/v1/users": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Create new user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Users" - ], - "summary": "Register user", - "parameters": [ - { - "description": "User data", - "name": "RegisterUserRequestDto", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dtos.RegisterUserRequestDto" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dtos.RegisterUserResponseDto" - } - } - } - } } }, "definitions": { @@ -372,49 +333,6 @@ const docTemplate = `{ } } }, - "dtos.RegisterUserRequestDto": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "password": { - "type": "string" - }, - "userName": { - "type": "string" - } - } - }, - "dtos.RegisterUserResponseDto": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "password": { - "type": "string" - }, - "userId": { - "type": "string" - }, - "userName": { - "type": "string" - } - } - }, "dtos.SearchProductsResponseDto": { "type": "object", "properties": { diff --git a/internal/services/product_service/docs/swagger.json b/internal/services/product_service/docs/swagger.json index d35df53..a4f1be9 100644 --- a/internal/services/product_service/docs/swagger.json +++ b/internal/services/product_service/docs/swagger.json @@ -245,45 +245,6 @@ } } } - }, - "/api/v1/users": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Create new user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Users" - ], - "summary": "Register user", - "parameters": [ - { - "description": "User data", - "name": "RegisterUserRequestDto", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dtos.RegisterUserRequestDto" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dtos.RegisterUserResponseDto" - } - } - } - } } }, "definitions": { @@ -360,49 +321,6 @@ } } }, - "dtos.RegisterUserRequestDto": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "password": { - "type": "string" - }, - "userName": { - "type": "string" - } - } - }, - "dtos.RegisterUserResponseDto": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "password": { - "type": "string" - }, - "userId": { - "type": "string" - }, - "userName": { - "type": "string" - } - } - }, "dtos.SearchProductsResponseDto": { "type": "object", "properties": { diff --git a/internal/services/product_service/docs/swagger.yaml b/internal/services/product_service/docs/swagger.yaml index fee6e97..bfb9c23 100644 --- a/internal/services/product_service/docs/swagger.yaml +++ b/internal/services/product_service/docs/swagger.yaml @@ -46,34 +46,6 @@ definitions: updatedAt: type: string type: object - dtos.RegisterUserRequestDto: - properties: - email: - type: string - firstName: - type: string - lastName: - type: string - password: - type: string - userName: - type: string - type: object - dtos.RegisterUserResponseDto: - properties: - email: - type: string - firstName: - type: string - lastName: - type: string - password: - type: string - userId: - type: string - userName: - type: string - type: object dtos.SearchProductsResponseDto: properties: products: @@ -258,30 +230,6 @@ paths: summary: Search products tags: - Products - /api/v1/users: - post: - consumes: - - application/json - description: Create new user - parameters: - - description: User data - in: body - name: RegisterUserRequestDto - required: true - schema: - $ref: '#/definitions/dtos.RegisterUserRequestDto' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dtos.RegisterUserResponseDto' - security: - - ApiKeyAuth: [] - summary: Register user - tags: - - Users securityDefinitions: ApiKeyAuth: in: header diff --git a/services/product_service/docs/docs.go b/services/product_service/docs/docs.go new file mode 100644 index 0000000..8e47450 --- /dev/null +++ b/services/product_service/docs/docs.go @@ -0,0 +1,490 @@ +// Package docs GENERATED BY SWAG; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/v1/products": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Get all products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get all product", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dtos.GetProductsResponseDto" + } + } + } + }, + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Create new product item", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Create product", + "parameters": [ + { + "description": "Product data", + "name": "CreateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.CreateProductRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dtos.CreateProductResponseDto" + } + } + } + } + }, + "/api/v1/products/search": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Search products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Search products", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "string", + "name": "search", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dtos.SearchProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/{id}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Get product by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dtos.GetProductByIdResponseDto" + } + } + } + }, + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Update existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Update product", + "parameters": [ + { + "description": "Product data", + "name": "UpdateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.UpdateProductRequestDto" + } + }, + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "" + } + } + }, + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Delete existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Delete product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "" + } + } + } + }, + "/api/v1/users": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Create new user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Register user", + "parameters": [ + { + "description": "User data", + "name": "RegisterUserRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.RegisterUserRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dtos.RegisterUserResponseDto" + } + } + } + } + } + }, + "definitions": { + "dtos.CreateProductRequestDto": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "inventoryId": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "dtos.CreateProductResponseDto": { + "type": "object", + "properties": { + "productId": { + "type": "string" + } + } + }, + "dtos.GetProductByIdResponseDto": { + "type": "object", + "properties": { + "product": { + "$ref": "#/definitions/dtos.ProductDto" + } + } + }, + "dtos.GetProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "type": "object" + } + } + }, + "dtos.ProductDto": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "inventoryId": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "productId": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "dtos.RegisterUserRequestDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, + "dtos.RegisterUserResponseDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userId": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, + "dtos.SearchProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "type": "object" + } + } + }, + "dtos.UpdateProductRequestDto": { + "type": "object", + "required": [ + "count", + "inventoryId", + "name", + "price" + ], + "properties": { + "count": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "inventoryId": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/services/product_service/docs/swagger.json b/services/product_service/docs/swagger.json new file mode 100644 index 0000000..d35df53 --- /dev/null +++ b/services/product_service/docs/swagger.json @@ -0,0 +1,462 @@ +{ + "swagger": "2.0", + "info": { + "contact": {} + }, + "paths": { + "/api/v1/products": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Get all products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get all product", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dtos.GetProductsResponseDto" + } + } + } + }, + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Create new product item", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Create product", + "parameters": [ + { + "description": "Product data", + "name": "CreateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.CreateProductRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dtos.CreateProductResponseDto" + } + } + } + } + }, + "/api/v1/products/search": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Search products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Search products", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "string", + "name": "search", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dtos.SearchProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/{id}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Get product by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dtos.GetProductByIdResponseDto" + } + } + } + }, + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Update existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Update product", + "parameters": [ + { + "description": "Product data", + "name": "UpdateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.UpdateProductRequestDto" + } + }, + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "" + } + } + }, + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Delete existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Delete product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "" + } + } + } + }, + "/api/v1/users": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Create new user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Register user", + "parameters": [ + { + "description": "User data", + "name": "RegisterUserRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dtos.RegisterUserRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dtos.RegisterUserResponseDto" + } + } + } + } + } + }, + "definitions": { + "dtos.CreateProductRequestDto": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "inventoryId": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "dtos.CreateProductResponseDto": { + "type": "object", + "properties": { + "productId": { + "type": "string" + } + } + }, + "dtos.GetProductByIdResponseDto": { + "type": "object", + "properties": { + "product": { + "$ref": "#/definitions/dtos.ProductDto" + } + } + }, + "dtos.GetProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "type": "object" + } + } + }, + "dtos.ProductDto": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "inventoryId": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "productId": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "dtos.RegisterUserRequestDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, + "dtos.RegisterUserResponseDto": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "userId": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, + "dtos.SearchProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "type": "object" + } + } + }, + "dtos.UpdateProductRequestDto": { + "type": "object", + "required": [ + "count", + "inventoryId", + "name", + "price" + ], + "properties": { + "count": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "inventoryId": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/services/product_service/docs/swagger.yaml b/services/product_service/docs/swagger.yaml new file mode 100644 index 0000000..fee6e97 --- /dev/null +++ b/services/product_service/docs/swagger.yaml @@ -0,0 +1,290 @@ +definitions: + dtos.CreateProductRequestDto: + properties: + count: + type: integer + description: + type: string + inventoryId: + type: integer + name: + type: string + price: + type: number + type: object + dtos.CreateProductResponseDto: + properties: + productId: + type: string + type: object + dtos.GetProductByIdResponseDto: + properties: + product: + $ref: '#/definitions/dtos.ProductDto' + type: object + dtos.GetProductsResponseDto: + properties: + products: + type: object + type: object + dtos.ProductDto: + properties: + count: + type: integer + createdAt: + type: string + description: + type: string + inventoryId: + type: integer + name: + type: string + price: + type: number + productId: + type: string + updatedAt: + type: string + type: object + dtos.RegisterUserRequestDto: + properties: + email: + type: string + firstName: + type: string + lastName: + type: string + password: + type: string + userName: + type: string + type: object + dtos.RegisterUserResponseDto: + properties: + email: + type: string + firstName: + type: string + lastName: + type: string + password: + type: string + userId: + type: string + userName: + type: string + type: object + dtos.SearchProductsResponseDto: + properties: + products: + type: object + type: object + dtos.UpdateProductRequestDto: + properties: + count: + type: integer + description: + type: string + inventoryId: + type: integer + name: + type: string + price: + type: number + required: + - count + - inventoryId + - name + - price + type: object + utils.FilterModel: + properties: + comparison: + type: string + field: + type: string + value: + type: string + type: object +info: + contact: {} +paths: + /api/v1/products: + get: + consumes: + - application/json + description: Get all products + parameters: + - in: query + name: orderBy + type: string + - in: query + name: page + type: integer + - in: query + name: size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dtos.GetProductsResponseDto' + security: + - ApiKeyAuth: [] + summary: Get all product + tags: + - Products + post: + consumes: + - application/json + description: Create new product item + parameters: + - description: Product data + in: body + name: CreateProductRequestDto + required: true + schema: + $ref: '#/definitions/dtos.CreateProductRequestDto' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dtos.CreateProductResponseDto' + security: + - ApiKeyAuth: [] + summary: Create product + tags: + - Products + /api/v1/products/{id}: + delete: + consumes: + - application/json + description: Delete existing product + parameters: + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: "" + security: + - ApiKeyAuth: [] + summary: Delete product + tags: + - Products + get: + consumes: + - application/json + description: Get product by id + parameters: + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dtos.GetProductByIdResponseDto' + security: + - ApiKeyAuth: [] + summary: Get product + tags: + - Products + put: + consumes: + - application/json + description: Update existing product + parameters: + - description: Product data + in: body + name: UpdateProductRequestDto + required: true + schema: + $ref: '#/definitions/dtos.UpdateProductRequestDto' + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: "" + security: + - ApiKeyAuth: [] + summary: Update product + tags: + - Products + /api/v1/products/search: + get: + consumes: + - application/json + description: Search products + parameters: + - in: query + name: orderBy + type: string + - in: query + name: page + type: integer + - in: query + name: search + type: string + - in: query + name: size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dtos.SearchProductsResponseDto' + security: + - ApiKeyAuth: [] + summary: Search products + tags: + - Products + /api/v1/users: + post: + consumes: + - application/json + description: Create new user + parameters: + - description: User data + in: body + name: RegisterUserRequestDto + required: true + schema: + $ref: '#/definitions/dtos.RegisterUserRequestDto' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dtos.RegisterUserResponseDto' + security: + - ApiKeyAuth: [] + summary: Register user + tags: + - Users +securityDefinitions: + ApiKeyAuth: + in: header + name: Authorization + type: apiKey +swagger: "2.0"