Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hippo-oss/openapi-decorators

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hippo-oss/openapi-decorators - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

dist/openapi/pick.d.ts

4

CHANGELOG.md
# Changelog
## [0.4.0]
- Implements `pick()` DTO operator.
## [0.3.0]

@@ -4,0 +8,0 @@

import { DTODecoratorFactories } from '@hippo-oss/dto-decorators';
export declare const OPENAPI_DECORATORS: DTODecoratorFactories;
export * from './pick';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -24,2 +34,3 @@ exports.OPENAPI_DECORATORS = void 0;

};
__exportStar(require("./pick"), exports);
//# sourceMappingURL=index.js.map

6

package.json
{
"name": "@hippo-oss/openapi-decorators",
"version": "0.3.0",
"version": "0.4.0",
"description": "DTO decorators with @nestjs/swagger.",

@@ -26,3 +26,4 @@ "main": "./dist/index.js",

"dependencies": {
"@hippo-oss/dto-decorators": ">=0.4.0"
"@hippo-oss/dto-decorators": ">=0.4.0",
"lodash": "4.17.21"
},

@@ -43,2 +44,3 @@ "peerDependencies": {

"@types/jest": "27.4.1",
"@types/lodash": "4.14.182",
"@types/node": "16.11.26",

@@ -45,0 +47,0 @@ "@types/validator": "13.7.1",

@@ -1,22 +0,9 @@

import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { Test } from '@nestjs/testing';
import { ExampleDTO, createController, createDocument } from './fixtures';
import { ExampleController } from './fixtures';
describe('decorators', () => {
it('generates OpenAPI spec', async () => {
const moduleRef = await Test.createTestingModule({
controllers: [
ExampleController,
],
}).compile();
const ExampleController = createController(ExampleDTO);
const app = moduleRef.createNestApplication();
const document = await createDocument(ExampleController);
const options = new DocumentBuilder()
.setTitle('Example')
.build();
const document = SwaggerModule.createDocument(app, options);
const response = document.paths['/example']?.get?.responses[200];

@@ -23,0 +10,0 @@ expect(response).toMatchObject({

@@ -1,3 +0,4 @@

import { Controller, Get } from '@nestjs/common';
import { ApiOkResponse } from '@nestjs/swagger';
import { Controller, Get, Type } from '@nestjs/common';
import { ApiOkResponse, DocumentBuilder, OpenAPIObject, SwaggerModule } from '@nestjs/swagger';
import { Test } from '@nestjs/testing';

@@ -39,3 +40,3 @@ import {

class ExampleDTO {
export class ExampleDTO {

@@ -221,13 +222,34 @@ /* Create one property of each type that is required. */

@Controller('example')
export class ExampleController {
export function createController(DTO: Type): Type {
@Get()
// NB: we normally rely on the OpenAPI CLI plugin to inject response decorators
@ApiOkResponse({
type: ExampleDTO,
})
public find(): ExampleDTO {
return {} as unknown as ExampleDTO;
@Controller('example')
class ExampleController {
@Get()
// NB: we normally rely on the OpenAPI CLI plugin to inject response decorators
@ApiOkResponse({
type: DTO,
})
public find(): typeof DTO {
return {} as unknown as typeof DTO;
}
}
return ExampleController;
}
export async function createDocument(ExampleController: Type): Promise<OpenAPIObject> {
const moduleRef = await Test.createTestingModule({
controllers: [
ExampleController,
],
}).compile();
const app = moduleRef.createNestApplication();
const options = new DocumentBuilder()
.setTitle('Example')
.build();
return SwaggerModule.createDocument(app, options);
}

@@ -24,1 +24,3 @@ import { DTODecoratorFactories } from '@hippo-oss/dto-decorators';

};
export * from './pick';

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc