{"id":22865548,"url":"https://github.com/tecfu/yup2swagger","last_synced_at":"2025-05-05T15:18:32.355Z","repository":{"id":51663981,"uuid":"224529655","full_name":"tecfu/yup2swagger","owner":"tecfu","description":"Convert your Yup object schema to a Swagger definition","archived":false,"fork":false,"pushed_at":"2021-05-10T20:25:50.000Z","size":18,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-15T22:12:00.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tecfu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-27T22:47:01.000Z","updated_at":"2024-04-15T22:12:00.675Z","dependencies_parsed_at":"2022-08-22T20:20:50.432Z","dependency_job_id":null,"html_url":"https://github.com/tecfu/yup2swagger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fyup2swagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fyup2swagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fyup2swagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fyup2swagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tecfu","download_url":"https://codeload.github.com/tecfu/yup2swagger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229538526,"owners_count":18088898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T11:37:36.210Z","updated_at":"2024-12-13T11:37:36.743Z","avatar_url":"https://github.com/tecfu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yup-to-swagger\n\n[![Build Status](https://travis-ci.org/tecfu/yup-to-swagger.svg?branch=master)](https://travis-ci.org/tecfu/yup-to-swagger) [![NPM version](https://badge.fury.io/js/yup-to-swagger.svg)](http://badge.fury.io/js/yup-to-swagger)\n\n---\n\nConvert Yup to Swagger. Transforms a Yup schema into a Swagger/OpenAPI yaml definition.\n\n---\n\n## Example\n\n```js\nconst yup = require('@tecfu/yup')\nconst yup2swag = require('yup-to-swagger')\n\nconst schema = yup\n  .object()\n  .meta({ \n    title: \"Title of my definition\",\n    description: \"Description of my definition\"\n  })\n  .shape({\n    id: yup.number().integer().positive().required(),\n    name: yup.string(),\n    email: yup.string().email().required(),\n    created: yup.date().nullable(),\n    active: yup.boolean().default(true)\n  })\n\nlet swaggerDefinition = yup2swag.parse(schema, {\n  extendedSwaggerFormats: true\n})\nconsole.log(swaggerDefinition)\n\n// type: object\n// title: Title of my definition\n// description: Description of my definition\n// required:\n//   - id\n//   - email\n// properties:\n//   id:\n//     type: integer\n//     minimum: 0\n//   name:\n//     type: string\n//   email:\n//     type: string\n//     format: email\n//   created:\n//     type: string\n//     format: date\n//     nullable: true\n//   active:\n//     type: boolean\n//     default: true\n\n```\n\nOr if you want JSON output:\n\n```js\n\nlet swaggerDefinition = yup2swag.parse(schema, {\n  extendedSwaggerFormats: true,\n  outputFormat: \"json\"\n})\nconsole.log(swaggerDefinition)\n\n// {\n//   type: 'object',\n//   title: 'Title of my definition',\n//   description: 'Description of my definition',\n//   required: [ 'id', 'email' ],\n//   properties: {\n//     id: { type: 'integer', minimum: 0 },\n//     name: { type: 'string' },\n//     email: { type: 'string', format: 'email' },\n//     created: { type: 'string', format: 'date', nullable: true },\n//     active: { type: 'boolean', default: true }\n//   }\n// }\n\n```\n\n## Please note:\n\nTo benefit from the full features of this package, please use the following fork of [Yup]( https://github.com/tecfu/yup ). \n\n```sh\nnpm i --save @tecfu/yup\n```\n\n## License\n\n[MIT License](https://opensource.org/licenses/MIT)\n\nCopyright 2019, Tecfu. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftecfu%2Fyup2swagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftecfu%2Fyup2swagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftecfu%2Fyup2swagger/lists"}