Skip to content

Conversation

@muningis
Copy link
Contributor

@muningis muningis commented Mar 22, 2025

This packages allows transforming OpenAPI Declarations (.yaml and .json) and JSON Schemas (tested and unit test covered with draft-07).

Some of JSON Schema validations (minProperties, maxProperties, isoDuration) are covered by #1100 (comment)

@vercel
Copy link

vercel bot commented Mar 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valibot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2025 9:39pm

@fabian-hiller fabian-hiller self-assigned this Mar 23, 2025
@fabian-hiller fabian-hiller added enhancement New feature or request question Further information is requested labels Mar 23, 2025
@fabian-hiller
Copy link
Member

Thanks for creating this PR! In simple words, is the general idea of this package to read a JSON or YAML file containing OpenAPI or JSON schema and convert it to a Valibot schema? If so, does it depend on Node.js to read the files? Can users also just pass an OpenAPI or JSON Schema object (without reading a file) to convert it to a Valibot schema? Does it make sense to split it into two packages from-josn-schema and from-openapi? On of the packages could use the other as a dependency.

@muningis
Copy link
Contributor Author

is the general idea of this package to read a JSON or YAML file containing OpenAPI or JSON schema and convert it to a Valibot schema

Yes, but not limited to that. With what we have, we could allow parsing other formats too.

If so, does it depend on Node.js to read the files? Can users also just pass an OpenAPI or JSON Schema object (without reading a file) to convert it to a Valibot schema?

It's up to users how they will retrieve said files. Something such as OpenAPI Declaration file would most likely retrieved over an API call. However, at the moment current implementation depends on node to write to the file system (we could allow instead just to return generated code so users can save it however they wish)

Does it make sense to split it into two packages from-josn-schema and from-openapi? On of the packages could use the other as a dependency.

I'm open to discussion, but don't really see benefit of that. Bundle size difference is barely noticeable, and it would only be ran on dev machine (or CI where code is built, considering types output gets .gitignored).

@muningis
Copy link
Contributor Author

Questionable functionalities, which can't be replicated by Typescript's types (but can be validated with custom validators/actions)

Additional concerns on https://json-schema.org/understanding-json-schema/reference/combining

  • anyOf, allOf, oneOf -> we can check for those, but probably in TS it could only be (T | U)[]
  • not -> we can check it (validate type and expect it to be not valid), but unsure if we can replicate in types, except maybe for type Not<T, U> = T extends U ? never : T; but I'm not too confident.

@fabian-hiller
Copy link
Member

Hey, I'm very sorry for my late reply, but I don't have much time right now. I recommend to continue this library as a community project for now because of time constraints on my side. Sorry for that! I am happy to help you share it on social media and connect you with other developers in our ecosystem if you are interested. Feel free to contact me again in about two months. I may have a little more time then. I also want to thank you for your recent contributions to the project! I hope to be able to give back some day! Please reach out if you are motivated to contribute even more. For example, we are looking for someone interested in investigating a possible VS Code extension implementation.

@muningis muningis closed this Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants