@@ -24,6 +24,9 @@ export const self = {
2424
2525// These functions will update the request.
2626// They'll be given {req, value, paramter, spec, operation}.
27+
28+ // TODO: OAS3: add builder for requestBody
29+ // QUESTION: OAS3: how do we decide which media type to use from a requestBody?
2730export const PARAMETER_BUILDERS = {
2831 body : bodyBuilder ,
2932 header : headerBuilder ,
@@ -120,6 +123,9 @@ export function buildRequest({
120123 const builder = parameterBuilders [ parameter . in ]
121124 let value
122125
126+ // REVIEW: OAS3: have any key names or parameter shapes changed?
127+ // Any new features that need to be plugged in here?
128+
123129 if ( parameter . in === 'body' && parameter . schema && parameter . schema . properties ) {
124130 value = parameters
125131 }
@@ -140,6 +146,7 @@ export function buildRequest({
140146 } )
141147
142148 // Add securities, which are applicable
149+ // REVIEW: OAS3: what changed in securities?
143150 req = applySecurities ( { request : req , securities, operation, spec} )
144151
145152 if ( req . body || req . form ) {
@@ -156,6 +163,7 @@ export function buildRequest({
156163 req . headers [ 'content-type' ] = 'multipart/form-data'
157164 }
158165 else if ( operation . parameters . filter ( p => p . in === 'formData' ) . length ) {
166+ // TODO: OAS3: disable this
159167 req . headers [ 'content-type' ] = 'application/x-www-form-urlencoded'
160168 }
161169 }
@@ -169,11 +177,13 @@ export function buildRequest({
169177
170178// Add the body to the request
171179export function bodyBuilder ( { req, value} ) {
180+ // REVIEW: OAS3: wtf does this do
172181 req . body = value
173182}
174183
175184// Add a form data object.
176185export function formDataBuilder ( { req, value, parameter} ) {
186+ // REVIEW: OAS3: check for any parameter changes that affect the builder
177187 req . form = req . form || { }
178188 if ( value || parameter . allowEmptyValue ) {
179189 req . form [ parameter . name ] = {
@@ -186,6 +196,7 @@ export function formDataBuilder({req, value, parameter}) {
186196
187197// Add a header to the request
188198export function headerBuilder ( { req, parameter, value} ) {
199+ // REVIEW: OAS3: check for any parameter changes that affect the builder
189200 req . headers = req . headers || { }
190201 if ( typeof value !== 'undefined' ) {
191202 req . headers [ parameter . name ] = value
@@ -194,11 +205,13 @@ export function headerBuilder({req, parameter, value}) {
194205
195206// Replace path paramters, with values ( ie: the URL )
196207export function pathBuilder ( { req, value, parameter} ) {
208+ // REVIEW: OAS3: check for any parameter changes that affect the builder
197209 req . url = req . url . replace ( `{${ parameter . name } }` , encodeURIComponent ( value ) )
198210}
199211
200212// Add a query to the `query` object, which will later be stringified into the URL's search
201213export function queryBuilder ( { req, value, parameter} ) {
214+ // REVIEW: OAS3: check for any parameter changes that affect the builder
202215 req . query = req . query || { }
203216
204217 if ( value === false && parameter . type === 'boolean' ) {
@@ -226,6 +239,9 @@ const stripNonAlpha = str => (str ? str.replace(/\W/g, '') : null)
226239
227240// Compose the baseUrl ( scheme + host + basePath )
228241export function baseUrl ( { spec, scheme, contextUrl = '' } ) {
242+ // TODO: OAS3: support `servers` instead of host+basePath
243+ // QUESTION: OAS3: how are we handling `servers`?
244+ // QUESTION: OAS3: are we still doing assumed URL components the same way?
229245 const parsedContextUrl = url . parse ( contextUrl )
230246 const firstSchemeInSpec = Array . isArray ( spec . schemes ) ? spec . schemes [ 0 ] : null
231247
0 commit comments