Skip to content

Commit

Permalink
fix(postman): fix naming and formatting
Browse files Browse the repository at this point in the history
fixes #250
  • Loading branch information
ostridm committed Oct 4, 2024
1 parent 412f687 commit f915e11
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/oas/src/converter/Converter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OpenAPI, Request } from '@har-sdk/core';

export interface ConverterOptions {
omitInferredAcceptHeadersInFavorOfParam?: boolean;
omitInferringAcceptHeadersInFavorOfParams?: boolean;
}

export interface Converter {
Expand Down
6 changes: 1 addition & 5 deletions packages/oas/src/converter/parts/SubConverterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export class SubConverterFactory {
Oas3HeadersConverter
);
case SubPart.PATH:
return this.instantiate(
spec,
Oas2PathConverter,
Oas3PathConverter
);
return this.instantiate(spec, Oas2PathConverter, Oas3PathConverter);
case SubPart.POST_DATA:
return this.instantiate(
spec,
Expand Down
8 changes: 4 additions & 4 deletions packages/oas/src/converter/parts/headers/HeadersConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export abstract class HeadersConverter<T extends OpenAPI.Document>
headers.push(...this.createContentTypeHeaders(pathObj));
}

const acceptHeaders = this.createAcceptHeaders(pathObj);
const acceptHeaders = this.createAcceptHeaders(pathObj);

const paramsHeaders = this.parseFromParams(path, method);
const paramsHeaders = this.parseFromParams(path, method);

const addInferred =
!this.options.omitInferredAcceptHeadersInFavorOfParam ||
!this.options.omitInferringAcceptHeadersInFavorOfParams ||
!paramsHeaders.some((x) => x.name === 'accept');

headers.push(...(addInferred ? acceptHeaders : []), ...paramsHeaders );
headers.push(...(addInferred ? acceptHeaders : []), ...paramsHeaders);

return headers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export class Oas2HeadersConverter extends HeadersConverter<OpenAPIV2.Document> {
private readonly oas2ValueSerializer = new Oas2ValueSerializer();
private readonly oas2MediaTypeResolver: Oas2MediaTypesResolver;

constructor(spec: OpenAPIV2.Document, sampler: Sampler, options: ConverterOptions) {
constructor(
spec: OpenAPIV2.Document,
sampler: Sampler,
options: ConverterOptions
) {
super(spec, sampler, options);
this.oas2MediaTypeResolver = new Oas2MediaTypesResolver(spec);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/oas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const oas2har = (
collection: OpenAPI.Document,
options: {
includeVendorExamples?: boolean;
omitInferredAcceptHeadersInFavorOfParam?: boolean;
omitInferringAcceptHeadersInFavorOfParams?: boolean;
} = {}
): Promise<Request[]> => {
if (!collection) {
Expand Down
2 changes: 1 addition & 1 deletion packages/oas/tests/DefaultConverter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ describe('DefaultConverter', () => {

// act
const result: Request[] = await oas2har(inputDoc as any, {
omitInferredAcceptHeadersInFavorOfParam: true
omitInferringAcceptHeadersInFavorOfParams: true
});

// assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ components:
type: string
name:
type: string

0 comments on commit f915e11

Please sign in to comment.