{"id":34666762,"url":"https://github.com/ts-oas/nest-openapi","last_synced_at":"2025-12-24T19:11:50.984Z","repository":{"id":310084003,"uuid":"1037602980","full_name":"ts-oas/nest-openapi","owner":"ts-oas","description":"A modern, modular set of utilities for building OpenAPI-driven NestJS apps.","archived":false,"fork":false,"pushed_at":"2025-12-03T19:33:43.000Z","size":244,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-07T00:58:41.045Z","etag":null,"topics":["ajv","nestjs","openapi","openapi3","openapi31","validation"],"latest_commit_sha":null,"homepage":"https://nest-openapi.github.io/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ts-oas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-13T20:38:07.000Z","updated_at":"2025-12-03T19:33:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"16db1754-4607-4f0e-abe7-a2baa095ddf8","html_url":"https://github.com/ts-oas/nest-openapi","commit_stats":null,"previous_names":["ts-oas/nest-openapi"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ts-oas/nest-openapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-oas%2Fnest-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-oas%2Fnest-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-oas%2Fnest-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-oas%2Fnest-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ts-oas","download_url":"https://codeload.github.com/ts-oas/nest-openapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-oas%2Fnest-openapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28006421,"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","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ajv","nestjs","openapi","openapi3","openapi31","validation"],"created_at":"2025-12-24T19:11:50.312Z","updated_at":"2025-12-24T19:11:50.976Z","avatar_url":"https://github.com/ts-oas.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./docs/public/nest-openapi-logo.png\" alt=\"nest-openapi-logo\" height=\"84\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e@nest-openapi\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\u003cstrong\u003eOpenAPI‑first utilities for NestJS\u003c/strong\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Single source of truth · Drop‑in for NestJS · Fast by design\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://deepwiki.com/ts-oas/nest-openapi\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/DeepWiki-ts--oas%2Fnest--openapi-blue.svg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z68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==\" alt=\"DeepWiki\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ts-oas/nest-openapi/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/ts-oas/nest-openapi\" alt=\"License\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Features\n\n- **🎯 Single Source of Truth** — Your OpenAPI spec drives validation, serialization, and mocking.\n- **⚡ Fast by Design** — AJV validation and `fast-json-stringify` serialization with caching and precompilation.\n- **🔌 Drop-in Integration** — Works with existing NestJS controllers and routes\n- **🎛️ Fine-Grained Control** — Per-route opt-out and custom schema overrides\n- **🚀 Platform Agnostic** — Supports both Express and Fastify adapters\n\n## Packages\n\n| Package                                                                              | Description                                                        | Version                                                                                                                     | Docs                                                  |\n| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |\n| [`@nest-openapi/validator`](https://www.npmjs.com/package/@nest-openapi/validator)   | Automatic request/response validation using your OpenAPI spec      | [![npm](https://img.shields.io/npm/v/@nest-openapi/validator.svg)](https://www.npmjs.com/package/@nest-openapi/validator)   | [📖 Docs](https://nest-openapi.github.io/validator/)  |\n| [`@nest-openapi/serializer`](https://www.npmjs.com/package/@nest-openapi/serializer) | High-performance response serialization based on your OpenAPI spec | [![npm](https://img.shields.io/npm/v/@nest-openapi/serializer.svg)](https://www.npmjs.com/package/@nest-openapi/serializer) | [📖 Docs](https://nest-openapi.github.io/serializer/) |\n| [`@nest-openapi/mock`](https://www.npmjs.com/package/@nest-openapi/mock)             | Spec-driven mock server for generating realistic mock responses    | [![npm](https://img.shields.io/npm/v/@nest-openapi/mock.svg)](https://www.npmjs.com/package/@nest-openapi/mock)             | [📖 Docs](https://nest-openapi.github.io/mock/)       |\n\n## Quick Start\n\n### Validator\n\n```bash\nnpm i @nest-openapi/validator\n```\n\n```typescript\nimport { Module } from \"@nestjs/common\";\nimport { OpenAPIValidatorModule } from \"@nest-openapi/validator\";\nimport * as openApiSpec from \"./openapi.json\";\n\n@Module({\n  imports: [\n    OpenAPIValidatorModule.forRoot({\n      specSource: { type: \"object\", spec: openApiSpec },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n**All routes are automatically validated.** See [full documentation](https://nest-openapi.github.io/validator/) for advanced configuration.\n\n### Serializer\n\n```bash\nnpm i @nest-openapi/serializer\n```\n\n```typescript\nimport { Module } from \"@nestjs/common\";\nimport { OpenAPISerializerModule } from \"@nest-openapi/serializer\";\nimport * as openApiSpec from \"./openapi.json\";\n\n@Module({\n  imports: [\n    OpenAPISerializerModule.forRoot({\n      specSource: { type: \"object\", spec: openApiSpec },\n      responseSerialization: { enable: true, skipErrorResponses: true },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n**Responses are automatically serialized.** See [full documentation](https://nest-openapi.github.io/serializer/) for advanced configuration.\n\n### Mock\n\n```bash\nnpm i @nest-openapi/mock\n```\n\n```typescript\nimport { Module } from \"@nestjs/common\";\nimport { OpenAPIMockModule } from \"@nest-openapi/mock\";\nimport * as openApiSpec from \"./openapi.json\";\n\n@Module({\n  imports: [\n    OpenAPIMockModule.forRoot({\n      specSource: { type: \"object\", spec: openApiSpec },\n      enable: process.env.NODE_ENV === \"development\",\n      mockByDefault: true,\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n**Routes return mocked responses when enabled.** See [full documentation](https://nest-openapi.github.io/mock/) for advanced configuration.\n\n## Usage Examples\n\n### Manual Validation\n\n```typescript\nimport { Inject, Injectable } from \"@nestjs/common\";\nimport {\n  OPENAPI_VALIDATOR,\n  OpenAPIValidatorService,\n} from \"@nest-openapi/validator\";\n\n@Injectable()\nexport class MyService {\n  constructor(\n    @Inject(OPENAPI_VALIDATOR)\n    private readonly validator: OpenAPIValidatorService\n  ) {}\n\n  validate(ctx: HttpArgumentsHost) {\n    const errors = this.validator.validateRequest(ctx, { body: true });\n    if (errors.length \u003e 0) {\n      // Handle validation errors\n    }\n  }\n}\n```\n\n### Per-Route Overrides\n\n```typescript\nimport { Controller, Post } from \"@nestjs/common\";\nimport { Validate } from \"@nest-openapi/validator\";\nimport { Serialize } from \"@nest-openapi/serializer\";\n\n@Controller(\"books\")\nexport class BooksController {\n  @Post()\n  @Validate({ request: { query: false }, response: true })\n  @Serialize({ disable: true })\n  create(@Body() dto: CreateBookDto): Book {\n    return this.booksService.create(dto);\n  }\n}\n```\n\n## Compatibility\n\n- Works with NestJS v9+\n- Supports Express and Fastify adopters\n\n## Contributing\n\nIssues and PRs are welcome. Please check the package folders and docs before opening an issue.\n\n## License\n\nMIT © [@nest-openapi](https://github.com/ts-oas/nest-openapi)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-oas%2Fnest-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fts-oas%2Fnest-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-oas%2Fnest-openapi/lists"}