-
Notifications
You must be signed in to change notification settings - Fork 636
Validator
The framework encourages design driven implementation so swagger specification should be done before the implementation starts. With the swagger-codegen undertow generator, the server stub can be generated and start running within minutes. However, we cannot rely on generator for validation as specification will be changed along the life cycle of the API. This is why we have provided a validator that works on top of the specification at runtime. In this way, the generator should only be used once and the validator will take the latest spec. and validate according the spec. at runtime.
This is the entry point of the validator and it is injected during server start up if validator.json enableValidator is true. By default, only RequestValidator will be called. However, ResponseValidator can be enabled by setting enableResponseValidator to true in validator.json.
It will validate the following:
- uri
- method
- header
- query parameters
- path parameters
- body if available
When necessary, schema validator will be called to do json schema validation.
It will validate the following: header response code body if available
when necessary, json schema validator will be called.
If schema is defined in swagger.json, then the json-schema-validator will be called.
In order to test validator, the test suite starts an undertow server and serves petstore api for testing. It is a demo on how to unit test your API during development.