Skip to content

New Feature: Annotation @HttpExpect #13

@olaferlandsen

Description

@olaferlandsen

With the @HttpExpect annotation you will be able to define the necessary rules to execute a service safely, validating each step.

  • Multiple Rules
  • @HttpExpect validate as custom validation function
  • @HttpExpect message as custom message error
  • @HttpExpect in
    • query - Query String
    • path - path url
    • cookie - Cookies
    • header - Headers
    • body - POST/PUT data
      • Conten-Type application/json
      • Conten-Type application/x-www-form-urlencoded
  • @HttpExpect type
    • Equal to String
    • Equal to Number
    • Equal to Object
    • Equal to Array
  • Create Unit Test
    • Try Unit Test
    • Passing Unit Test

@HttpExpect Options

Option Possible Values Optional Default Value Data Type
in 'header', 'path', 'query', 'body', 'cookie' query string
type Object, String, Array and Number String Constructor
required true, false false boolean
default undefined string, boolean, array, number

Example

@Api
export class MyController {
    @HttpGet()
    @HttpExpect({
        'id' : {
            type : String,
            in: 'query'
            required: true,
            default:0
        }
    })
    public get () {
        return this.httpOk(this.queryString().id);
    }
}

Alternative Example

@Api
export class MyController {
    @HttpGet()
    @HttpExpect({
        'id' : Number  // Default in query as Number
    })
    public get () {
        return this.httpOk(this.queryString().id);
    }
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions