GithubHelp home page GithubHelp logo

Comments (7)

santhosh-tekuri avatar santhosh-tekuri commented on May 13, 2024

schema annotations (title, description, default, readOnly, writeOnly, examples) are commonly used for documentation. they don't participate in document validation. In order to avoid memory, they are not included in compiled schema definition.

Could you explain the use case, why you need them...

from jsonschema.

maroux avatar maroux commented on May 13, 2024

That's fair. My use case is code generation. We use json schema to validate the transport payload of messages between micro services and when a golang service receives a message I want to be able to use strong typing rather than empty struct maps.

I was able to generate the code using this library but I was hoping to add docstrings based on json schema descriptions.

from jsonschema.

handrews avatar handrews commented on May 13, 2024

@santhosh-tekuri annotations are increasingly important in JSON Schema, and will become more so. While it's definitely fine to implement just validation (a formal process of annotation collection only really became defined in draft-07 and is getting refined for draft-08, but is not a required feature), pretty much every usage of JSON Schema beyond validation relies on it.

I assume that most implementations will either choose to optimize for validation or will provide full functionality including annotation collection. So perhaps just a clear statement as to which you intend this project to be in your README would help.

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on May 13, 2024

@maroux I understand that description can be used as doc strings in generated go structures. I am interested in your project. if it is open-source please share the link.

@handrews in my old project i used RAML in internet devices. these devices has less RAM. so i have to traverse compiled RAML and make all annotations nil, to reduce memory footprint. So I did not keep annotations in compiled schema.

I will add Compiler.ExtractAnnotations = true/false flag which defaults to false, so that developers who do not need annotations can still discard them in compiled schema.

from jsonschema.

maroux avatar maroux commented on May 13, 2024

@santhosh-tekuri I don't have it completed yet - still a WIP evaluating which json schema library makes most sense for this project. Seeing the difference between docstring vs no docstring its pretty clear that docstrings are a deal breaker for this particular use case.

I like the extract annotations suggestion.

from jsonschema.

handrews avatar handrews commented on May 13, 2024

json-schema-org/json-schema-spec#530 if you want to give feedback on the whole annotations collection process for the next draft.

from jsonschema.

maroux avatar maroux commented on May 13, 2024

wow, thanks for the quick update!

from jsonschema.

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.