11import type { AuthForHAR , DataForHAR , oasToHarOptions } from './lib/types.js' ;
22import type { PostData , PostDataParams , Request } from 'har-format' ;
3+ import type Oas from 'oas' ;
34import type { Extensions } from 'oas/extensions' ;
45import type {
56 HttpMethods ,
67 JSONSchema ,
78 MediaTypeObject ,
8- OASDocument ,
99 OperationObject ,
1010 ParameterObject ,
1111 SchemaObject ,
@@ -14,7 +14,6 @@ import type {
1414} from 'oas/types' ;
1515
1616import { parse as parseDataUrl } from '@readme/data-urls' ;
17- import Oas from 'oas' ;
1817import { HEADERS , PROXY_ENABLED } from 'oas/extensions' ;
1918import { Operation } from 'oas/operation' ;
2019import { isRef } from 'oas/types' ;
@@ -274,9 +273,8 @@ export default function oasToHar(
274273 *
275274 * It's weird. This is easier.
276275 */
277- const currentOas = Oas . init ( oas as unknown as OASDocument ) ;
278276 operation = new Operation (
279- currentOas ,
277+ oas ,
280278 operationSchema ?. path || '' ,
281279 operationSchema ?. method || ( '' as HttpMethods ) ,
282280 ( operationSchema as unknown as OperationObject ) || { path : '' , method : '' } ,
@@ -296,13 +294,13 @@ export default function oasToHar(
296294 if ( ! formData . server ) {
297295 formData . server = {
298296 selected : 0 ,
299- variables : oas . defaultVariables ( 0 ) ,
297+ variables : operation . defaultVariables ( 0 ) ,
300298 } ;
301299 }
302300
303301 // If the incoming `server.variables` is missing variables let's pad it out with defaults.
304302 formData . server . variables = {
305- ...oas . defaultVariables ( formData . server . selected ) ,
303+ ...operation . defaultVariables ( formData . server . selected ) ,
306304 ...( formData . server . variables ? formData . server . variables : { } ) ,
307305 } ;
308306
@@ -315,7 +313,7 @@ export default function oasToHar(
315313 postData : { } ,
316314 bodySize : 0 ,
317315 method : operation . method . toUpperCase ( ) ,
318- url : `${ oas . url ( formData . server . selected , formData . server . variables as ServerVariable ) } ${ operation . path } ` . replace (
316+ url : `${ operation . url ( formData . server . selected , formData . server . variables as ServerVariable ) } ${ operation . path } ` . replace (
319317 / \s / g,
320318 '%20' ,
321319 ) ,
0 commit comments