diff --git a/internal/server/swagger.yml b/internal/server/swagger.yml new file mode 100644 index 0000000..211299f --- /dev/null +++ b/internal/server/swagger.yml @@ -0,0 +1,160 @@ +openapi: 3.0.0 +info: + title: Crafting Table API + version: 0.1.9 + +servers: + - url: http://localhost:7628 + description: Main server + + +paths: + '/api/db/generate': + post: + tags: + - database + summary: create a new repository + requestBody: + content: + application/json: + schema: + type: object + properties: + source: + type: string + destination: + type: string + destination_file_name: + type: string + struct_name: + type: string + table_name: + type: string + get: + type: array + update: + type: array + get_offset: + type: integer + create: + type: object + properties: + enable: + type: boolean + costum_function_name: + type: string + create_test: + type: boolean + join: + type: array + + example: + source: "./example/src/example.go" + destination: "./example/dst/" + destination_file_name: "example_repo" + struct_name: "Example2" + table_name: "example" + get: [ + { + conditions: ['var1', 'var2'], + costum_fileds: [], + costum_function_name: "GetData" + }, + { + conditions: ['var3'], + costum_fileds: ["var2"], + costum_function_name: "GetVar2" + } + ] + get_offset: 12 + update: [ + { + conditions: ['var1', 'var2'], + fields: ['var3'], + costum_function_name: "UpdateData" + }, + { + conditions: ['var4'], + fields: ['var2', 'var3'], + costum_function_name: "UpdateVar2" + } + ] + create: { + enable: true, + costum_function_name: "CreateData" + } + create_test: true + join: [ + { + join_struct_name: "Example", + join_table_name: "example2", + join_type: "LEFT OUTER", + join_field_as: "var13", + join_on: "var1", + costum_function_name: "JoinData" + } + ] + + responses: + 201: + description: 'db repository created successfully' + content: + application/json: + schema: + $ref: '#/components/schemas/DBGenerate' + 500: + description: 'internal server error' + + '/api/db/get-structs': + post: + tags: + - database + summary: get all structs of a file + requestBody: + content: + application/json: + schema: + type: object + properties: + source: + type: string + example: + source: "./example/src/example.go" + + responses: + 201: + description: 'db repository created successfully' + content: + application/json: + schema: + $ref: '#/components/schemas/DBGetStructs' + 500: + description: 'internal server error' + +components: + schemas: + DBGenerate: + type: object + properties: + status: + type: string + example: "success" + data: + type: object + properties: + message: + type: string + example: "db repository created successfully" + + DBGetStructs: + type: object + properties: + status: + type: string + example: "success" + data: + type: object + properties: + structs: + type: array + example: ["Example", "Example2"]