Skip to content

Commit

Permalink
use openapi plugin for proposal module - changes introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
emigun committed Jan 22, 2025
1 parent 7bb617f commit 116a49c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/proposals/dto/create-measurement-period.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsDateString, IsOptional, IsString } from "class-validator";

export class CreateMeasurementPeriodDto {
Expand Down
1 change: 0 additions & 1 deletion src/proposals/dto/create-proposal.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsString } from "class-validator";
import { UpdateProposalDto } from "./update-proposal.dto";

Expand Down
2 changes: 1 addition & 1 deletion src/proposals/dto/update-proposal.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiProperty, ApiTags, PartialType } from "@nestjs/swagger";
import { ApiTags, PartialType } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsArray,
Expand Down
1 change: 0 additions & 1 deletion src/proposals/schemas/measurement-period.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { ApiProperty } from "@nestjs/swagger";
import { Document } from "mongoose";
import { QueryableClass } from "src/common/schemas/queryable.schema";

Expand Down
39 changes: 13 additions & 26 deletions src/proposals/schemas/proposal.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { ApiHideProperty, ApiProperty } from "@nestjs/swagger";
import { ApiHideProperty } from "@nestjs/swagger";
import { Document, Schema as MongooseSchema } from "mongoose";

import { OwnableClass } from "src/common/schemas/ownable.schema";
Expand Down Expand Up @@ -137,43 +137,30 @@ export class ProposalClass extends OwnableClass {
})
MeasurementPeriodList?: MeasurementPeriodClass[];

@ApiProperty({
type: MongooseSchema.Types.Mixed,
required: false,
default: {},
description: "JSON object containing the proposal metadata.",
})
/**
* JSON object containing the proposal metadata.
*/
@Prop({ type: MongooseSchema.Types.Mixed, required: false, default: {} })
metadata?: Record<string, unknown>;
metadata?: Record<string, unknown> = {};

@ApiProperty({
type: String,
required: false,
description: "Parent proposal id",
default: null,
nullable: true,
})
/**
* Parent proposal id
*/
@Prop({
type: String,
required: false,
default: null,
ref: "Proposal",
})
parentProposalId: string;
parentProposalId: string | null = null;

@ApiProperty({
type: String,
required: true,
default: DEFAULT_PROPOSAL_TYPE,
description:
"Characterize type of proposal, use some of the configured values",
})
/**
* Characterize type of proposal, use some of the configured values
*/
@Prop({
type: String,
required: true,
default: DEFAULT_PROPOSAL_TYPE,
})
type: string;
type: string = DEFAULT_PROPOSAL_TYPE;
}

export const ProposalSchema = SchemaFactory.createForClass(ProposalClass);
Expand Down

0 comments on commit 116a49c

Please sign in to comment.