type OpenApiSpec = {
  openapi: string;
  info: {
    title: string;
    version: string;
    description: string;
  };
  servers: Array<{ url: string }>;
  paths: Record<string, unknown>;
};

export const buildOpenApiSpec = (baseUrl: string, widgetFilename: string): OpenApiSpec => {
  return {
    openapi: "3.0.0",
    info: {
      title: "ProovIT MCP Server",
      version: "1.0.0",
      description: "Public metadata endpoints for the ProovIT MCP server."
    },
    servers: [{ url: baseUrl }],
    paths: {
      "/health": {
        get: {
          summary: "Health check",
          responses: {
            "200": {
              description: "OK"
            }
          }
        }
      },
      "/app.json": {
        get: {
          summary: "App manifest",
          responses: {
            "200": {
              description: "App manifest"
            }
          }
        }
      },
      "/.well-known/app.json": {
        get: {
          summary: "Well-known app manifest",
          responses: {
            "200": {
              description: "App manifest"
            }
          }
        }
      },
      "/.well-known/ai-plugin.json": {
        get: {
          summary: "AI plugin manifest",
          responses: {
            "200": {
              description: "AI plugin manifest"
            },
            "404": {
              description: "Not configured"
            }
          }
        }
      },
      "/proovit.html": {
        get: {
          summary: "Widget HTML",
          responses: {
            "200": {
              description: "Widget HTML"
            }
          }
        }
      },
      [`/${widgetFilename}`]: {
        get: {
          summary: "Widget HTML (versioned)",
          responses: {
            "200": {
              description: "Widget HTML"
            }
          }
        }
      }
    }
  };
};
