Giter VIP home page Giter VIP logo

Comments (4)

bioball avatar bioball commented on May 18, 2024 2

Good timing; we just submitted apple/pkl-pantry#12 that adds support for this!

from pkl.

bioball avatar bioball commented on May 18, 2024

That PR has landed.

You can generate Pkl schema from JSON Schema; for example:

pkl eval package://pkg.pkl-lang.org/pkl-pantry/[email protected]#/generate.pkl -m . -p source="https://json.schemastore.org/github-action.json"

Note: depending on the input JSON Schema, you might need to tinker with the generated result to make it more useful. Some of JSON Schema is more expressive than Pkl; take a look at the docs for more details: https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib/current/generate/index.html

from pkl.

buremba avatar buremba commented on May 18, 2024

Great to hear! JSON Schema also conditional blocks i.e if/else and I assume that it's not supported yet. Not sure if it's feasible in addition to the work for anyOf/allOff but maybe something to consider.
BTW, the speed you ship the integrations today is impressive. This was something that I tried with Jsonnet a while and I couldn't manage to get it done in a seamless way. Great work!

from pkl.

gobetti avatar gobetti commented on May 18, 2024

generate.pkl works great and was absolutely critical for our team to start considering pkl adoption, thank you for that 👏

I see apple/pkl-pantry#12 mentions it:

provides support for generating JSON Schema from Pkl

but I'm wondering if one is actually able to convert Pkl classes into a JSON Schema; for example:

  1. use generate.pkl to generate Pkl from a JSON Schema
  2. now de-transform the generated Pkl code back into a JSON Schema

I'm describing the scenario above just to be clear about what kind of Pkl code I'm trying to convert to a JSON Schema, in general I don't expect people to do those exact 2 steps. But something like those steps would be helpful for our project to confidently migrate from JSON Schemas to Pkl, and not have to change all the systems to Pkl at once.

Thank you!

from pkl.

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.