import type { OpenAPIV3_1 } from "openapi-types";

export const getDatamartSpec: OpenAPIV3_1.PathsObject = {
	"/api/datamart/{name}": {
		get: {
			summary: "Runs the query by name",
			description:
				"This will allow to run any query by its name and optional parameters to be sent over as well, up to 3 params can be added",
			tags: ["Datamart"],

			parameters: [
				{
					name: "name",
					in: "path",
					required: false,
					description: "Name to look up",
					schema: {
						type: "string",
					},
					example: "exampleName",
				},
				{
					name: "limit",
					in: "query",
					required: false, // 👈 optional
					description: "Maximum number of records to return",
					schema: {
						type: "integer",
						minimum: 1,
						maximum: 100,
					},
					example: 10,
				},
			],

			responses: {
				"200": {
					description: "Successful response",
					content: {
						"application/json": {
							schema: {
								type: "object",
								properties: {
									success: { type: "boolean", example: true },
									data: {
										type: "object",
										example: {
											name: "exampleName",
											value: "some value",
										},
									},
								},
							},
						},
					},
				},
				"400": {
					description: "Bad request",
					content: {
						"application/json": {
							schema: {
								type: "object",
								properties: {
									success: { type: "boolean", example: false },
									message: {
										type: "string",
										example: "Invalid name parameter",
									},
								},
							},
						},
					},
				},
			},
		},
	},
};
