Giter Site home page Giter Site logo

Comments (7)

Eomm avatar Eomm commented on June 12, 2024 3

Switching the ajv version is as easy as writing:

const factoryValidator = require('@fastify/ajv-compiler')()

const app = fastify({
  schemaController: {
    compilersFactory: {
      buildValidator: factoryValidator
    }
  }
})

Since changing the default would be a massive breaking change for the user (as it should rewrite all its schemas) - we could just ship a new @fastify/ajv-compiler major with ajv/2020 and let those users that want the new standard set the buildValidator option accordingly.

from fastify.

gurgunday avatar gurgunday commented on June 12, 2024 1

It's also important to note that, and this is what changed my mind on this, the AJV docs recommend sticking with 07 if we don't need the two new properties as all schemas will be affected by the reduced performance required to support them

fastify/ajv-compiler#105 (comment)
https://ajv.js.org/guide/schema-language.html#draft-2019-09-and-draft-2020-12

So it seems logical for me to keep the default 7 and let the user configure the setting

from fastify.

climba03003 avatar climba03003 commented on June 12, 2024

Draft 7 and Draft 2020-12 is great different.
It also provides a large set of incompatibility.

from fastify.

kibertoad avatar kibertoad commented on June 12, 2024

@climba03003 Do you mean that existing Draft 7 schemas will stop working under Draft 2020?

from fastify.

climba03003 avatar climba03003 commented on June 12, 2024

Do you mean that existing Draft 7 schemas will stop working under Draft 2020?

Mostly, yes. If it can works, I don't see a reason why, ajv would split into different version.

https://json-schema.org/draft/2019-09/release-notes
https://json-schema.org/draft/2020-12/release-notes

from fastify.

metcoder95 avatar metcoder95 commented on June 12, 2024

Draft-2020 is also marked as non-backwards compatible by ajv: https://ajv.js.org/json-schema.html#draft-2020-12

It would be nice but a lot of schemas uses mostly the 2019-draft, and doing this make them prone to break and cause friction with the adoption of Fastify v5.

Might be better to allow them do it if they want or still use 2019's draft

from fastify.

mcollina avatar mcollina commented on June 12, 2024

I think we would need fast-json-stringify to support it first.

from fastify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.