Skip to content

Commit

Permalink
docs: typo
Browse files Browse the repository at this point in the history
Typo
  • Loading branch information
Yaapa Hage committed Apr 17, 2020
1 parent 55f5fed commit cf12a69
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions docs/site/LB3-vs-LB4-request-response-cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ The request/response architecture has undergone a drastic change in LoopBack 4.
LoopBack 3's
[phase-based middleware routing system](https://loopback.io/doc/en/lb3/Routing.html)
is now replaced by a
[sequence handler](./apidocs/apidocs.rest.defaultsequence.md)
that sits infront of a
[routing table](./apidocs/apidocs.rest.routingtable.md).
[sequence handler](./apidocs/apidocs.rest.defaultsequence.md) that sits infront
of a [routing table](./apidocs/apidocs.rest.routingtable.md).

In LoopBack 3, middleware are added using Express APIs and via phases in
`middleware.json` or using
Expand Down Expand Up @@ -372,10 +371,10 @@ thus have access to the request and response objects.
LoopBack 4, refer to the
[validation doc](./Validation.md)." %}

[strong-remoting](https://github.com/strongloop/strong-remoting) is the core
of data coercion and validation in LoopBack 3. Validation rules are defined
using the `accepts` metadata and data-access level
validation are defined by model validation methods like `validatesPresenceOf()`.
[strong-remoting](https://github.com/strongloop/strong-remoting) is the core of
data coercion and validation in LoopBack 3. Validation rules are defined using
the `accepts` metadata and data-access level validation are defined by model
validation methods like `validatesPresenceOf()`.

`strong-remoting`'s supported data types can be found in its
[type definitions](https://github.com/strongloop/strong-remoting/tree/master/lib/types)
Expand All @@ -388,34 +387,34 @@ LoopBack 4 does a full JSON Schema validation at the REST layer and
property-based validation at the data-access layer.

OpenAPI is used to describe the type and constraints of request parameters in
LoopBack 4. In a typical controller, OpenAPI schemas describing the model
data are built from the metadata provided by LoopBack Models. Non-model
parameters (e.g. id in `findById(id)`, `filter` in `find(filter)`) are
described using inline schema.
LoopBack 4. In a typical controller, OpenAPI schemas describing the model data
are built from the metadata provided by LoopBack Models. Non-model parameters
(e.g. id in `findById(id)`, `filter` in `find(filter)`) are described using
inline schema.

When a request arrives, a light weight
[coercion](https://github.com/strongloop/loopback-next/blob/master/packages/rest/src/coercion/coerce-parameter.ts)
and
[validation](https://github.com/strongloop/loopback-next/blob/master/packages/rest/src/coercion/validator.ts)
is performed on the request body at OpenAPI parameters level. Then, the
OpenAPI schema is converted to JSON schema on which
is performed on the request body at OpenAPI parameters level. Then, the OpenAPI
schema is converted to JSON schema on which
[AJV validation](https://github.com/strongloop/loopback-next/tree/master/packages/rest/src/validation)
is run against the schema.

Currently, LoopBack 4 does not validate non-body parameters against schema. It
will be supported in future, follow
[this issue](https://github.com/strongloop/loopback-next/issues/1573)
to keep track of the progress.
[this issue](https://github.com/strongloop/loopback-next/issues/1573) to keep
track of the progress.

In LoopBack 4, it is possible to apply additional validation of model data at
the REST layer via `jsonSchema` model setting, which can partially replace
advanced validations provided by LoopBack 3 at data-access level. However, it
is not a direct replacement for Model validation methods in LoopBack 3. The
former performs the validation at the REST API layer, while the later performs
the validation at the data access layer; that means, the data validation of
advanced validations provided by LoopBack 3 at data-access level. However, it is
not a direct replacement for Model validation methods in LoopBack 3. The former
performs the validation at the REST API layer, while the later performs the
validation at the data access layer; that means, the data validation of
`jsonSchema` will not be applied if data is modifiued using repository methods.

Here is an example of enforcing the string length of a model property usin
Here is an example of enforcing the string length of a model property using
`jsonSchema` in LoopBack 4:

```ts
Expand Down

0 comments on commit cf12a69

Please sign in to comment.