New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openapi-typescript

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-typescript - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

4

bin/cli.js

@@ -145,5 +145,5 @@ #!/usr/bin/env node

if (cli.flags.output !== "." && output === OUTPUT_FILE) {
let outputDir = path.join(process.cwd(), cli.flags.output);
let outputDir = path.resolve(process.cwd(), cli.flags.output);
if (isGlob) {
outputDir = path.join(outputDir, path.dirname(specPath)); // globs: use output dir + spec dir
outputDir = path.resolve(outputDir, path.dirname(specPath)); // globs: use output dir + spec dir
} else {

@@ -150,0 +150,0 @@ outputDir = path.dirname(outputDir); // single files: just use output parent dir

@@ -26,3 +26,13 @@ "use strict";

function transformAnyOf(anyOf, options) {
return utils_1.tsIntersectionOf(anyOf.map((s) => utils_1.tsPartial(transformSchemaObj(s, options))));
const schemas = anyOf.filter((s) => {
if (Object.keys(s).length > 1)
return true;
if (s.required)
return false;
return true;
});
if (schemas.length === 0) {
return "";
}
return utils_1.tsIntersectionOf(schemas.map((s) => utils_1.tsPartial(transformSchemaObj(s, options))));
}

@@ -29,0 +39,0 @@ exports.transformAnyOf = transformAnyOf;

@@ -90,5 +90,6 @@ "use strict";

function tsIntersectionOf(types) {
if (types.length === 1)
return types[0];
return `(${types.join(") & (")})`;
const typesWithValues = types.filter(Boolean);
if (typesWithValues.length === 1)
return typesWithValues[0];
return `(${typesWithValues.join(") & (")})`;
}

@@ -95,0 +96,0 @@ exports.tsIntersectionOf = tsIntersectionOf;

@@ -22,3 +22,13 @@ import { comment, nodeType, tsArrayOf, tsIntersectionOf, tsPartial, tsReadonly, tsTupleOf, tsUnionOf } from "../utils";

export function transformAnyOf(anyOf, options) {
return tsIntersectionOf(anyOf.map((s) => tsPartial(transformSchemaObj(s, options))));
const schemas = anyOf.filter((s) => {
if (Object.keys(s).length > 1)
return true;
if (s.required)
return false;
return true;
});
if (schemas.length === 0) {
return "";
}
return tsIntersectionOf(schemas.map((s) => tsPartial(transformSchemaObj(s, options))));
}

@@ -25,0 +35,0 @@ export function transformOneOf(oneOf, options) {

@@ -78,5 +78,6 @@ export function comment(text) {

export function tsIntersectionOf(types) {
if (types.length === 1)
return types[0];
return `(${types.join(") & (")})`;
const typesWithValues = types.filter(Boolean);
if (typesWithValues.length === 1)
return typesWithValues[0];
return `(${typesWithValues.join(") & (")})`;
}

@@ -83,0 +84,0 @@ export function tsPartial(type) {

{
"name": "openapi-typescript",
"description": "Generate TypeScript types from Swagger OpenAPI specs",
"version": "4.0.0",
"version": "4.0.1",
"engines": {

@@ -63,3 +63,3 @@ "node": ">= 10.0.0"

"node-fetch": "^2.6.1",
"prettier": "^2.3.0",
"prettier": "^2.3.1",
"tiny-glob": "^0.2.9"

@@ -72,12 +72,12 @@ },

"@types/node-fetch": "^2.5.10",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"codecov": "^3.8.2",
"eslint": "^7.27.0",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.0.3",
"ts-jest": "^27.0.2",
"jest": "^27.0.4",
"ts-jest": "^27.0.3",
"typescript": "^4.2.4"
}
}

@@ -63,3 +63,3 @@ [![version(scoped)](https://img.shields.io/npm/v/openapi-typescript.svg)](https://www.npmjs.com/package/openapi-typescript)

_Note: for obvious reasons, globbing doesn’t work for remote schemas_
_Note: globbing doesn’t work for remote schemas because there is no reliable way to determine a list of files to select from a remote file system._

@@ -66,0 +66,0 @@ _Thanks to [@psmyrdek](https://github.com/psmyrdek) for the remote spec feature!_

@@ -42,3 +42,15 @@ import { GlobalContext } from "../types";

export function transformAnyOf(anyOf: any, options: TransformSchemaObjOptions): string {
return tsIntersectionOf(anyOf.map((s: any) => tsPartial(transformSchemaObj(s, options))));
// filter out anyOf keys that only have a `required` key. #642
const schemas = anyOf.filter((s: any) => {
if (Object.keys(s).length > 1) return true;
if (s.required) return false;
return true;
});
if (schemas.length === 0) {
return "";
}
return tsIntersectionOf(schemas.map((s: any) => tsPartial(transformSchemaObj(s, options))));
}

@@ -45,0 +57,0 @@

@@ -122,4 +122,6 @@ import { OpenAPI2, OpenAPI3, ReferenceObject } from "./types";

export function tsIntersectionOf(types: string[]): string {
if (types.length === 1) return types[0]; // don’t add parentheses around one thing
return `(${types.join(") & (")})`;
const typesWithValues = types.filter(Boolean);
if (typesWithValues.length === 1) return typesWithValues[0]; // don’t add parentheses around one thing
return `(${typesWithValues.join(") & (")})`;
}

@@ -126,0 +128,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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