Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Validation - Order schema validation is broken #532

Open
nh-mdev opened this issue Oct 27, 2020 · 0 comments
Open

Validation - Order schema validation is broken #532

nh-mdev opened this issue Oct 27, 2020 · 0 comments

Comments

@nh-mdev
Copy link

nh-mdev commented Oct 27, 2020

Version

vue-storefront-api 1.12.3

Scope

Checkout process > creating/submitting order via endpoint "/api/order"
Entry point: "src/api/order.ts"

Affacted files

  • "src/api/order.ts"
  • "src/platform/magento2/o2m.js"

Description

Expected behaviour

The received order json object should be validated according to the json schemas:
"src/models/order.schema.js"
"src/models/order.schema.extension.json" (optional)

Actual behaviour

The received order json object is not properly validated against the "order.schema.js" schema.
In fact, the validation always returns true, regardless of the properties composition and values the order json object contains.

Any additional rules in "order.schema.extension.json" are correctly triggered and can lead to a failed or successful validation result.

Reproduction steps

  1. Send an empty json object to the endpoint "/api/order/" via POST request (.e.g. via POSTMAN or INSOMNIA)
  2. It will not fail due to validation errors but rather further along in the code (see picture)

image

Possible resolutions

  1. Change all occurrences of "require('../../models/order.schema.js')" to "require('../../models/order.schema.js').default"

or

  1. Change the file name of "src/order.schema.js" to "src/order.schema.json" and remove "exports.default =" from line 1.

Impact of change

  1. Most likely a breaking change and might cause widespread failure of the route endpoint, since user implementations never had to pay attention to their order json object structure.
  2. Most likely the validation rules inside "order.schema" would have to be re-tested and possibly rewritten.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant