Giter VIP home page Giter VIP logo

Comments (3)

naz avatar naz commented on July 28, 2024

There were couple approaches considered as a fix:

  1. Having separate admin-api-validator instance per API - this would ensure schemas are never mixed in the cache.
  2. Use additional prefix/postfix when identifying $id in schema

1st approach pros/cons

pros:

  • no need to modify schemas
  • no maintenance for prefix/postfix when new version is released

cons:

  • package API needs to change to create a separate instance of ajv validator
  • need to change Ghost core to use new API
  • adds burden on the client user to "remember" to have a separate instance per API, and not being able to retreive/validate schemas on the same validator instance (unfriendly dev-experience imo)

2nd approach pros/cons

pros:

  • no changes to API or clients
  • keeps full functionality and single interface to access schemas/validations form any API version

cons:

  • need to maintain API prefix/postfix in the schema when creating new schema version folder

Given that the con from 2nd approach only happens 1 time a year (during new version release) and is pretty straight forward search/replace will go down this path. Also, there's possibility to automate this with a script if it's ever painful! IMO, keeping friendly, no "hidden tricks" package api and less changes in Ghost core far outweighs small maintenance burden.

from sdk.

naz avatar naz commented on July 28, 2024

Considerations around prefix or postfix naming change

There's not much difference in either approach. The only reason going with postfix notation $id: "{resource}.{version}" e.g.: "$id": "labels.canary" is to avoid regressions in existing use-case where error message is formed here.

from sdk.

naz avatar naz commented on July 28, 2024

For reference "$id" property naming conventions for JSON Schema - https://json-schema.org/understanding-json-schema/structuring.html#the-id-property. There is no specific convention enforced except:

The $id property should never be the empty string or an empty fragment (#), since that doesn’t really make sense.

And it's primary goal is:

The $id property is a URI-reference that serves two purposes:

  • It declares a unique identifier for the schema.
  • It declares a base URI against which $ref URI-references are resolved.

from sdk.

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.