@luvio/model
Advanced tools
Comparing version 3.5.0 to 3.5.1
@@ -37,5 +37,5 @@ /** | ||
this.path = this.amfEndPoint.path.value(); | ||
this.uriParameters = this.amfEndPoint.parameters.map((param) => { | ||
return { | ||
name: param.name.value(), | ||
this.uriParameters = {}; | ||
this.amfEndPoint.parameters.forEach((param) => { | ||
this.uriParameters[`${param.name}`] = { | ||
required: param.required.value(), | ||
@@ -55,8 +55,13 @@ type: amfTypeFactory(param.schema, typeRegistry, logger, true), | ||
this.method = this.amfOperation.method.value().toUpperCase(); | ||
// TODO: the following will properly populate the operationId member from OpenAPI YAML files, | ||
// but will return undefined for RAML files. We'll need to account for extensions to work | ||
// around this. | ||
this.operationId = this.amfOperation.operationId.value(); | ||
this.requests = this.amfOperation.requests.map((request) => { | ||
return { | ||
queryParameters: this.buildQueryParams(request), | ||
queryParameters: this.buildParams(request.queryParameters), | ||
uriParameters: this.buildParams(request.uriParameters), | ||
payloads: this.buildPayloads(request), | ||
cookies: this.buildCookies(request), | ||
headers: this.buildHeaders(request), | ||
cookies: this.buildParams(request.cookieParameters), | ||
headers: this.buildParams(request.headers), | ||
}; | ||
@@ -67,3 +72,3 @@ }); | ||
statusCode: response.statusCode.value(), | ||
headers: this.buildHeaders(response), | ||
headers: this.buildParams(response.headers), | ||
payloads: this.buildPayloads(response), | ||
@@ -81,6 +86,6 @@ }; | ||
} | ||
buildQueryParams(r) { | ||
return r.queryParameters.map((param) => { | ||
return { | ||
name: param.name.value(), | ||
buildParams(p) { | ||
const params = {}; | ||
p.forEach((param) => { | ||
params[`${param.name.value()}`] = { | ||
required: param.required.value(), | ||
@@ -90,21 +95,4 @@ type: this.amfTypeFactory(param.schema, this.typeRegistry, this.logger, true), | ||
}); | ||
return params; | ||
} | ||
buildHeaders(r) { | ||
return r.headers.map((amfHeader) => { | ||
return { | ||
name: amfHeader.name.value(), | ||
required: amfHeader.required.value(), | ||
type: this.amfTypeFactory(amfHeader.schema, this.typeRegistry, this.logger, true), | ||
}; | ||
}); | ||
} | ||
buildCookies(r) { | ||
return r.cookieParameters.map((cookie) => { | ||
return { | ||
name: cookie.name.value(), | ||
required: cookie.required.value(), | ||
type: this.amfTypeFactory(cookie.schema, this.typeRegistry, this.logger, true), | ||
}; | ||
}); | ||
} | ||
} | ||
@@ -657,11 +645,12 @@ | ||
this._servers = this.webApi.servers.map((s) => { | ||
const uriParameters = {}; | ||
s.variables.forEach((param) => { | ||
uriParameters[`${param.name.value()}`] = { | ||
required: param.required.value(), | ||
type: amfTypeFactory(param.schema, this.types, this.logger), | ||
}; | ||
}); | ||
return { | ||
url: s.url.value(), | ||
uriParameters: s.variables.map((param) => { | ||
return { | ||
name: param.name.value(), | ||
required: param.required.value(), | ||
type: amfTypeFactory(param.schema, this.types, this.logger), | ||
}; | ||
}), | ||
uriParameters, | ||
}; | ||
@@ -668,0 +657,0 @@ }); |
@@ -12,4 +12,4 @@ import type { EndPoint, Parameter } from '../../Endpoint'; | ||
path: string; | ||
uriParameters: Parameter[]; | ||
uriParameters: Record<string, Parameter>; | ||
constructor(amfEndPoint: amf.EndPoint, operations: AmfOperation[], amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
} |
@@ -12,2 +12,3 @@ import type * as amf from 'amf-client-js'; | ||
method: HttpMethod; | ||
operationId: string; | ||
requests: Request[]; | ||
@@ -17,5 +18,3 @@ responses: Response[]; | ||
buildPayloads(r: amf.Request | amf.Response): Payload[]; | ||
buildQueryParams(r: amf.Request): Parameter[]; | ||
buildHeaders(r: amf.Request | amf.Response): Parameter[]; | ||
buildCookies(r: amf.Request): Parameter[]; | ||
buildParams(p: amf.Parameter[]): Record<string, Parameter>; | ||
} |
@@ -19,3 +19,3 @@ import type { EndPoint, Parameter } from './Endpoint'; | ||
url: string; | ||
uriParameters: Parameter[]; | ||
uriParameters: Record<string, Parameter>; | ||
}; |
@@ -1,7 +0,6 @@ | ||
import type { StringType, Type } from './Type'; | ||
import type { ScalarType, Type } from './Type'; | ||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; | ||
export type StatusCode = '100' | '101' | '102' | '103' | '200' | '201' | '202' | '203' | '204' | '205' | '206' | '207' | '208' | '226' | '300' | '301' | '302' | '303' | '304' | '305' | '306' | '307' | '308' | '400' | '401' | '402' | '403' | '404' | '405' | '406' | '407' | '408' | '409' | '410' | '411' | '412' | '413' | '414' | '415' | '416' | '417' | '418' | '421' | '422' | '423' | '424' | '425' | '426' | '428' | '429' | '431' | '451' | '500' | '501' | '502' | '503' | '504' | '505' | '506' | '507' | '508' | '510' | '511'; | ||
export type Parameter = { | ||
name: string; | ||
type: StringType; | ||
type: ScalarType; | ||
required: boolean; | ||
@@ -19,6 +18,7 @@ }; | ||
export type Request<T extends Type = Type> = { | ||
queryParameters: Parameter[]; | ||
queryParameters: Record<string, Parameter>; | ||
uriParameters: Record<string, Parameter>; | ||
payloads: Array<Payload<T>>; | ||
cookies: Parameter[]; | ||
headers: Parameter[]; | ||
cookies: Record<string, Parameter>; | ||
headers: Record<string, Parameter>; | ||
}; | ||
@@ -28,6 +28,7 @@ export type Response<T extends Type = Type> = { | ||
payloads: Array<Payload<T>>; | ||
headers: Parameter[]; | ||
headers: Record<string, Parameter>; | ||
}; | ||
export type Operation<ResponseType extends Type = Type, RequestType extends Type = Type> = { | ||
method: HttpMethod; | ||
operationId: string; | ||
requests: Request<RequestType>[]; | ||
@@ -41,4 +42,4 @@ responses: Response<ResponseType>[]; | ||
path: string; | ||
uriParameters: Parameter[]; | ||
uriParameters: Record<string, Parameter>; | ||
operations: ReadonlyArray<Operation>; | ||
}; |
{ | ||
"name": "@luvio/model", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "Luvio model", | ||
@@ -24,3 +24,3 @@ "repository": { | ||
"dependencies": { | ||
"@luvio/utils": "^3.5.0", | ||
"@luvio/utils": "^3.5.1", | ||
"amf-client-js": "^5.2.3" | ||
@@ -27,0 +27,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
45482
23
1097
Updated@luvio/utils@^3.5.1