import { schema as RolesEndpointsSchema } from "../schemas/roles-endpoint.schema";
import { schema as DeleteSchema } from "../schemas/delete.schema";

import mongoose from "mongoose";
import { customsSchema } from "./abstract.model";

const collection = "roles-endpoints";

const schemaModelsMongoose = RolesEndpointsSchema.mongoose(
  RolesEndpointsSchema.schemas.parentSchema
);
const AbstractSchemaOptions = {
  timestamps: true,
  versionKey: false,
};
const Schema = new mongoose.Schema(schemaModelsMongoose, AbstractSchemaOptions);

customsSchema(Schema);

const getItem = {
  ...RolesEndpointsSchema.swagger({
    _id: "String",
    ...RolesEndpointsSchema.schemas.parentSchema,
  }).definitions,
  endpoint: { $ref: "#/definitions/" + "EndpointsGetItemSchema" },
};
const deleteItem = DeleteSchema.swagger(
  DeleteSchema.schemas.parentSchema
).definitions;

export const RolesEndpointsModel = mongoose.model(collection, Schema);
export const RolesEndpointsModelSwagger = {
  RolesEndpointsGetItem: {
    type: "object",
    properties: getItem,
  },
  RolesEndpointsGetItems: {
    type: "object",
    properties: getItem,
  },
  RolesEndpointsCreateItem: {
    type: "object",
    properties: getItem,
  },
  RolesEndpointsUpdateItem: {
    type: "object",
    properties: getItem,
  },
  RolesEndpointsDeleteItem: {
    type: "object",
    properties: deleteItem,
  },
};
