openapi3-ts
Advanced tools
Comparing version 3.1.1 to 3.1.2
# Changelog: openapi3-ts | ||
## Version 3.1.2 | ||
2022.11.19 | ||
- PR [#91](https://github.com/metadevpro/openapi3-ts/pull/91) Fix `addPath` to include merge semantics. Contributed by @MaurerKrisztian | ||
## Version 3.1.1 | ||
@@ -5,0 +11,0 @@ |
@@ -6,2 +6,5 @@ "use strict"; | ||
class OpenApiBuilder { | ||
static create(doc) { | ||
return new OpenApiBuilder(doc); | ||
} | ||
constructor(doc) { | ||
@@ -30,5 +33,2 @@ this.rootDoc = doc || { | ||
} | ||
static create(doc) { | ||
return new OpenApiBuilder(doc); | ||
} | ||
getSpec() { | ||
@@ -90,3 +90,3 @@ return this.rootDoc; | ||
addPath(path, pathItem) { | ||
this.rootDoc.paths[path] = pathItem; | ||
this.rootDoc.paths[path] = Object.assign(Object.assign({}, this.rootDoc.paths[path] || {}), pathItem); | ||
return this; | ||
@@ -93,0 +93,0 @@ } |
@@ -76,3 +76,3 @@ import { ISpecificationExtension } from './SpecificationExtension.js'; | ||
} | ||
export declare type PathObject = PathsObject; | ||
export type PathObject = PathsObject; | ||
export declare function getPath(pathsObject: PathsObject, path: string): PathItemObject | undefined; | ||
@@ -112,4 +112,4 @@ export interface PathItemObject extends ISpecificationExtension { | ||
} | ||
export declare type ParameterLocation = 'query' | 'header' | 'path' | 'cookie'; | ||
export declare type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject'; | ||
export type ParameterLocation = 'query' | 'header' | 'path' | 'cookie'; | ||
export type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject'; | ||
export interface BaseParameterObject extends ISpecificationExtension { | ||
@@ -218,3 +218,3 @@ description?: string; | ||
export declare function isReferenceObject(obj: any): obj is ReferenceObject; | ||
declare type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array'; | ||
type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array'; | ||
export interface SchemaObject extends ISpecificationExtension { | ||
@@ -277,3 +277,3 @@ nullable?: boolean; | ||
} | ||
export declare type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'; | ||
export type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'; | ||
export interface SecuritySchemeObject extends ISpecificationExtension { | ||
@@ -280,0 +280,0 @@ type: SecuritySchemeType; |
@@ -1,4 +0,4 @@ | ||
export declare type IExtensionName = `x-${string}`; | ||
export declare type IExtensionType = any; | ||
export declare type ISpecificationExtension = { | ||
export type IExtensionName = `x-${string}`; | ||
export type IExtensionType = any; | ||
export type ISpecificationExtension = { | ||
[extensionName: IExtensionName]: IExtensionType; | ||
@@ -5,0 +5,0 @@ }; |
import * as yaml from 'yaml'; | ||
export class OpenApiBuilder { | ||
static create(doc) { | ||
return new OpenApiBuilder(doc); | ||
} | ||
constructor(doc) { | ||
@@ -26,5 +29,2 @@ this.rootDoc = doc || { | ||
} | ||
static create(doc) { | ||
return new OpenApiBuilder(doc); | ||
} | ||
getSpec() { | ||
@@ -86,3 +86,3 @@ return this.rootDoc; | ||
addPath(path, pathItem) { | ||
this.rootDoc.paths[path] = pathItem; | ||
this.rootDoc.paths[path] = { ...this.rootDoc.paths[path] || {}, ...pathItem }; | ||
return this; | ||
@@ -89,0 +89,0 @@ } |
@@ -76,3 +76,3 @@ import { ISpecificationExtension } from './SpecificationExtension.js'; | ||
} | ||
export declare type PathObject = PathsObject; | ||
export type PathObject = PathsObject; | ||
export declare function getPath(pathsObject: PathsObject, path: string): PathItemObject | undefined; | ||
@@ -112,4 +112,4 @@ export interface PathItemObject extends ISpecificationExtension { | ||
} | ||
export declare type ParameterLocation = 'query' | 'header' | 'path' | 'cookie'; | ||
export declare type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject'; | ||
export type ParameterLocation = 'query' | 'header' | 'path' | 'cookie'; | ||
export type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject'; | ||
export interface BaseParameterObject extends ISpecificationExtension { | ||
@@ -218,3 +218,3 @@ description?: string; | ||
export declare function isReferenceObject(obj: any): obj is ReferenceObject; | ||
declare type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array'; | ||
type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array'; | ||
export interface SchemaObject extends ISpecificationExtension { | ||
@@ -277,3 +277,3 @@ nullable?: boolean; | ||
} | ||
export declare type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'; | ||
export type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'; | ||
export interface SecuritySchemeObject extends ISpecificationExtension { | ||
@@ -280,0 +280,0 @@ type: SecuritySchemeType; |
@@ -1,4 +0,4 @@ | ||
export declare type IExtensionName = `x-${string}`; | ||
export declare type IExtensionType = any; | ||
export declare type ISpecificationExtension = { | ||
export type IExtensionName = `x-${string}`; | ||
export type IExtensionType = any; | ||
export type ISpecificationExtension = { | ||
[extensionName: IExtensionName]: IExtensionType; | ||
@@ -5,0 +5,0 @@ }; |
{ | ||
"name": "openapi3-ts", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "TS Model & utils for OpenAPI 3.x specification.", | ||
@@ -36,9 +36,9 @@ "main": "dist/cjs/index.js", | ||
"devDependencies": { | ||
"@types/node": "^18.8.2", | ||
"@typescript-eslint/eslint-plugin": "^5.39.0", | ||
"@typescript-eslint/parser": "^5.39.0", | ||
"@vitest/coverage-c8": "^0.23.4", | ||
"@types/node": "^18.11.9", | ||
"@typescript-eslint/eslint-plugin": "^5.43.0", | ||
"@typescript-eslint/parser": "^5.43.0", | ||
"@vitest/coverage-c8": "^0.25.2", | ||
"c8": "^7.12.0", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^8.24.0", | ||
"eslint": "^8.28.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
@@ -48,6 +48,6 @@ "eslint-plugin-prettier": "^4.2.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "~4.8.4", | ||
"vitest": "^0.23.4", | ||
"vitest-teamcity-reporter": "^0.1.9" | ||
"typescript": "~4.9.3", | ||
"vitest": "^0.25.2", | ||
"vitest-teamcity-reporter": "^0.1.10" | ||
} | ||
} |
@@ -132,4 +132,15 @@ import { OpenApiBuilder } from '.'; | ||
}; | ||
const sut = OpenApiBuilder.create().addPath('/path1', path1).rootDoc; | ||
expect(sut.paths['/path1']).eql(path1); | ||
const doc = OpenApiBuilder.create().addPath('/path1', path1); | ||
expect(doc.rootDoc.paths['/path1']).eql(path1); | ||
const path2 = { | ||
post: { | ||
responses: { | ||
default: { | ||
description: 'object 2 created' | ||
} | ||
} | ||
} | ||
}; | ||
doc.addPath('/path1', path2) | ||
expect(doc.rootDoc.paths['/path1']).eql({...path1, ...path2}); | ||
}); | ||
@@ -136,0 +147,0 @@ |
@@ -102,3 +102,3 @@ import * as yaml from 'yaml'; | ||
addPath(path: string, pathItem: oa.PathItemObject): OpenApiBuilder { | ||
this.rootDoc.paths[path] = pathItem; | ||
this.rootDoc.paths[path] = {...this.rootDoc.paths[path] || {}, ...pathItem}; | ||
return this; | ||
@@ -105,0 +105,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93143
2450