Coder Social home page Coder Social logo

yup-to-json-schema's People

Contributors

bluelovers avatar daddywarbucks avatar deltazero-cz avatar marnulombard avatar raaghu avatar sodaru-it avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yup-to-json-schema's Issues

When property is not getting added when Yup to Json

HI Team,

I am trying to get the below Json format

"RegistrationNumber": {
"type": "string",
"when": {
"SearchRegoOrManual": { "is": "RegistrationNumber", "then": { "required": true } },
},
}

by using yup.string().when("SearchRegoOrManual", {is: "RegistrationNumber". then : yup.number().required() })

but in the output we are getting the expected output.

Please help

Support Yup V1

I've got working version of support for Yup V1 on my forked repo that I plan to open a PR for soon. This is a full rewrite and may require a major version. I actually got a few PR's merged in Yup specifically for this case. See : jquense/yup#1887

  • Supports nullable()
  • Support for the new getDefault()
  • Better required() support with how Yup V1 changed. It now has an optional flag instead of relying on the tests array.
  • General cleanup and type improvements.
  • Relies solely on the result of describe() instead of digging around in schema internals
  • Various other bug fixes and improvements found along the way.

PR coming soon!

Merge additional info from meta()

It would be helpful if the metadata helper merged additional properties onto the JSON Schema. https://github.com/sodaru/yup-to-json-schema/blob/main/src/converters/commonMetadata.ts should be updated to merge shape.spec.meta.jsonSchema properties onto the jsonSchema.
For example

if (shape.spec.meta?.jsonSchema) {
  Object.assign(jsonSchema, shape.spec.meta.jsonSchema);
}

This would allow the user to pass any arbitrary keys to .meta({ jsonSchema: { ... } }) which would allow them to customize this library while still keeping the library JSON Schema compliant.

I am using Swagger to create a docs website. Swagger supports the example and examples keywords, even though example is no longer valid. With this update, I could still use example with the following:

yup.object({
  name: yup.string().meta({ jsonSchema: { example: 'DaddyWarbucks' } })
})

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.