Coder Social home page Coder Social logo

Comments (4)

rs avatar rs commented on May 22, 2024 1

Yes, you can't modify the content of the reference from the parent document in the current state of the code.

from rest-layer.

smyrman avatar smyrman commented on May 22, 2024 1

(...) As you can imagine, this poses a small problem, as we would presumably need access to the index.

For JSON Schema used with the Swagger 2.0 specification (a.k.a. OPEN API Specification), we can actually avoid the resource.Index dependency completely by using the "$ref" keyword. If we can accept no type to be defined when using JSON Schema without swagger, this solution could be good enough...

Swagger 2.0 defines all payloads for an API under the "definitions" parameter in the root schema. Therefore, we can refer to the ref validator schema definition as "myRef": {"$ref": "#/definitions/{TypeName}/id"}.

Note that {TypeName} is most correctly spelled singular and possibly capitalized, so it should not be taken directly from the reference path. The reference path can also be deep. This must however be solved anyway to enable Swagger 2.0 documentation, so it's not a Reference specific problem.

from rest-layer.

smyrman avatar smyrman commented on May 22, 2024

UPDATE: if #100 is fixed/merged, there is an opportunity to access the Validator of the linked ID we are targeting if the schema is registered with a resource.Resource within a resource.Index that gets compiled.

This way we could embed an actual validator for the field rather than a reference, and we do not have to implement Swagger 2.0 support in order to close this issue.

from rest-layer.

smyrman avatar smyrman commented on May 22, 2024

UPDATE: if #100 is fixed/merged, there is an opportunity to access the Validator of the linked ID we are targeting if the schema is registered with a resource.Resource within a resource.Index that gets compiled.

The way this has been implemented, the related validator is kept private. I want to revisit how JSON Schema (and ptentially other doc formats) gets generated after #77, so I am dropping this from the 0.2 milestone.

from rest-layer.

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.