-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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
- Conten-Type
-
- @HttpExpect
type
- Equal to
String
- Equal to
Number
- Equal to
Object
- Equal to
Array
- Equal to
- 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 requestNew feature or request