npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hazeljs/swagger

v2.0.0

Published

Swagger/OpenAPI documentation module for HazelJS framework

Readme

@hazeljs/swagger

OpenAPI 3.0 documents and Swagger UI for HazelJS: class-level @Swagger, method-level @ApiOperation, automatic operation stubs for undocumented routes, and a small runtime config API.

npm version License: Apache-2.0

Installation

npm install @hazeljs/swagger @hazeljs/core

Quick start

1. Import the module and register your app root

import { HazelModule } from '@hazeljs/core';
import { SwaggerModule } from '@hazeljs/swagger';

@HazelModule({
  imports: [SwaggerModule],
  controllers: [
    /* ... */
  ],
})
export class AppModule {}

// After you create the app (e.g. where you bootstrap HazelApp):
SwaggerModule.setRootModule(AppModule);

2. Optional: document metadata, servers, auth, UI CDN, global prefix

SwaggerModule.configure({
  title: 'My API',
  description: 'Production API',
  version: '1.0.0',
  servers: [{ url: 'http://localhost:3000', description: 'Local' }],
  globalPrefix: '/api', // match app.setGlobalPrefix('/api') so paths and Swagger UI spec URL align
  securitySchemes: {
    bearer: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
  },
  security: [{ bearer: [] }],
  swaggerUiCdnBase: 'https://unpkg.com/[email protected]',
});

// Replace all options (e.g. in tests):
SwaggerModule.configure({}, true);

3. Decorate controllers

import { Controller, Get, Post, Body } from '@hazeljs/core';
import { Swagger, ApiOperation } from '@hazeljs/swagger';

@Swagger({
  title: 'Users API',
  description: 'User operations',
  version: '1.0.0',
  tags: [{ name: 'users', description: 'Users' }],
})
@Controller({ path: '/users' })
export class UserController {
  @Get()
  @ApiOperation({
    summary: 'List users',
    responses: { '200': { description: 'OK' } },
  })
  list() {
    return [];
  }

  @Post()
  @ApiOperation({
    summary: 'Create user',
    requestBody: {
      required: true,
      content: { 'application/json': { schema: { type: 'object' } } },
    },
    responses: { '201': { description: 'Created' } },
  })
  create(@Body() body: unknown) {
    return body;
  }
}

Routes without @ApiOperation still appear in the spec when autoGenerateOperations is true (default): summaries and placeholder request bodies are inferred from HTTP method and handler name. Set autoGenerateOperations: false in SwaggerModule.configure or pass { autoGenerateOperations: false } to SwaggerService.generateSpec to disable that for programmatic builds.

4. Open the UI and raw spec

  • Swagger UI: GET /swagger/ (or GET {globalPrefix}/swagger/ if configured)
  • OpenAPI JSON: GET /swagger/spec

Programmatic export (CI / codegen)

import { createOpenApiDocument } from '@hazeljs/swagger';
import { AppModule } from './app.module';
import * as fs from 'node:fs';

const doc = createOpenApiDocument(AppModule, {
  title: 'My API',
  version: '1.0.0',
  globalPrefix: '/api',
});
fs.writeFileSync('openapi.json', JSON.stringify(doc, null, 2));

YAML is not built in; pipe JSON through your preferred YAML tool if needed.

API reference

| Export | Role | | ----------------------- | --------------------------------------------------------------------------- | | SwaggerModule | Nest-style module; setRootModule, configure, getOptions | | SwaggerService | generateAutoSpec(module, options?), generateSpec(controllers, options?) | | createOpenApiDocument | Stateless helper around generateAutoSpec | | @Swagger | Class-level OpenAPI info / default tags | | @ApiOperation | Per-route operation (summary, parameters, requestBody, responses) |

Default components include Error and ValidationError schemas. Auto-generated error responses reference #/components/schemas/Error.

Roadmap / not implemented

The following are not in this package today (do not rely on READMEs or examples that mention Nest’s full @nestjs/swagger surface):

  • @ApiTags, @ApiResponse, @ApiProperty, @ApiParam, @ApiQuery, @ApiBody, @ApiHeader, @ApiBearerAuth, @ApiSecurity as separate decorators
  • DTO / class reflection for schemas
  • Built-in YAML export or SwaggerModule.forRoot static module factory

Contributions welcome for any of the above.

Testing

npm test

License

Apache 2.0 © HazelJS