diff --git a/src/models/v3/channel-parameter.ts b/src/models/v3/channel-parameter.ts index b5fc343e4..54099a351 100644 --- a/src/models/v3/channel-parameter.ts +++ b/src/models/v3/channel-parameter.ts @@ -1,12 +1,10 @@ import { BaseModel } from '../base'; -import { Schema } from './schema'; - import { hasDescription, description, extensions } from './mixins'; +import { Schema } from './schema'; import type { ChannelParameterInterface } from '../channel-parameter'; import type { SchemaInterface } from '../schema'; import type { ExtensionsInterface } from '../extensions'; - import type { v3 } from '../../spec-types'; export class ChannelParameter extends BaseModel implements ChannelParameterInterface { @@ -15,12 +13,23 @@ export class ChannelParameter extends BaseModel export interface ParameterObject extends SpecificationExtensions { description?: string; - schema?: SchemaObject; + enum?: string[]; + default?: string; + examples?: string[]; location?: string; } diff --git a/test/models/v3/channel-parameter.spec.ts b/test/models/v3/channel-parameter.spec.ts index 66c6c76a1..16eb510e5 100644 --- a/test/models/v3/channel-parameter.spec.ts +++ b/test/models/v3/channel-parameter.spec.ts @@ -43,12 +43,23 @@ describe('ChannelParameter model', function() { }); describe('.hasSchema()', function() { - it('should return true when there is a value', function() { - const doc = serializeInput({ schema: {} }); + it('should return true if enum are sat', function() { + const doc = serializeInput({ enum: ['test'] }); + const d = new ChannelParameter(doc); + expect(d.hasSchema()).toEqual(true); + }); + it('should return true if default are sat', function() { + const doc = serializeInput({ default: 'test' }); const d = new ChannelParameter(doc); expect(d.hasSchema()).toEqual(true); }); + it('should return true if examples are sat', function() { + const doc = serializeInput({ examples: ['test'] }); + const d = new ChannelParameter(doc); + expect(d.hasSchema()).toEqual(true); + }); + it('should return false when there is no value', function() { const doc = serializeInput({}); const d = new ChannelParameter(doc); @@ -57,10 +68,23 @@ describe('ChannelParameter model', function() { }); describe('.schema()', function() { - it('should return the value', function() { - const doc = serializeInput({ schema: {} }); + it('should be able to access enum values', function() { + const doc = serializeInput({ enum: ['test'] }); + const d = new ChannelParameter(doc); + expect(d.schema()).toBeInstanceOf(Schema); + expect(d.schema()?.enum()).toEqual(['test']); + }); + it('should be able to access examples values', function() { + const doc = serializeInput({ examples: ['test'] }); + const d = new ChannelParameter(doc); + expect(d.schema()).toBeInstanceOf(Schema); + expect(d.schema()?.examples()).toEqual(['test']); + }); + it('should be able to access default value', function() { + const doc = serializeInput({ default: 'test' }); const d = new ChannelParameter(doc); expect(d.schema()).toBeInstanceOf(Schema); + expect(d.schema()?.default()).toEqual('test'); }); it('should return undefined when there is no value', function() {