"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeIsPagingToSwagger = void 0;
const typeGenerator_1 = require("./generators/typeGenerator");
const isClass_1 = __importDefault(require("../utils/isClass"));
const toSwaggerGenerator_1 = require("./generators/toSwaggerGenerator");
const router_1 = require("@asapjs/router");
exports.TypeIsPagingToSwagger = (0, toSwaggerGenerator_1.toSwaggerGenerator)((options) => {
    var _a;
    const isDto = (0, isClass_1.default)(options);
    const generateScheme = (items) => ({
        type: 'object',
        properties: {
            data: {
                type: 'array',
                items,
            },
            page: {
                type: 'integer',
                format: 'int32',
                description: '현재 페이지',
            },
            page_size: {
                type: 'integer',
                format: 'int32',
                description: '페이지당 표시 개수',
            },
            max_page: {
                type: 'integer',
                format: 'int32',
                description: '최대 페이지',
            },
            has_prev: {
                type: 'boolean',
                format: 'boolean',
                description: '이전 이동가능 여부',
            },
            has_Next: {
                type: 'boolean',
                format: 'boolean',
                description: '다음 이동가능 여부',
            },
            total_elements: {
                type: 'integer',
                format: 'int32',
                description: '전체 레코드 개수',
            },
        },
    });
    if (isDto) {
        const dto = new options();
        const name = `${dto.constructor.name}_PAGING`;
        (0, router_1.addScheme)({
            name,
            data: generateScheme(dto.swagger()),
        });
        return {
            $ref: `#/components/schemas/${name}`,
        };
    }
    else {
        const type = options();
        const name = `TYPE_${type.__name.toUpperCase()}_PAGING`;
        (0, router_1.addScheme)({
            name,
            data: generateScheme((_a = type.toSwagger) === null || _a === void 0 ? void 0 : _a.call(type)),
        });
        return {
            $ref: `#/components/schemas/${name}`,
        };
    }
});
const TypeIsPaging = (0, typeGenerator_1.typeGenerator)((options) => ({
    __name: 'array',
    toSwagger: () => (0, exports.TypeIsPagingToSwagger)(options),
}));
exports.default = TypeIsPaging;
//# sourceMappingURL=paging.js.map