Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

fix: another attempt to get lodash working #248

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"extends": ["@readme/eslint-config", "@readme/eslint-config/typescript"],
"extends": ["@readme/eslint-config", "@readme/eslint-config/typescript", "@readme/eslint-config/esm"],
"root": true,
"rules": {
// `any` types are fine because we're dealing with a lot of unknown data.
"@typescript-eslint/no-explicit-any": "off",

"unicorn/prefer-node-protocol": "error",

"you-dont-need-lodash-underscore/get": "off"
}
}
37 changes: 29 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"scripts": {
"build": "tsup",
"lint": "eslint .",
"lint": "eslint . && tsc --noEmit",
"prebuild": "rm -rf dist/",
"prepack": "npm run build",
"prepare": "husky install",
Expand All @@ -55,7 +55,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@readme/eslint-config": "^12.2.1",
"@readme/eslint-config": "^13.0.1",
"@readme/oas-examples": "^5.12.0",
"@types/har-format": "^1.2.12",
"@types/lodash": "^4.14.198",
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types';
import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';
import type { Extensions } from '@readme/oas-extensions';
import type { PostDataParams, Request } from 'har-format';
import type Oas from 'oas';
Expand All @@ -17,15 +17,15 @@ import type {

import { parse as parseDataUrl } from '@readme/data-urls';
import { getExtension, PROXY_ENABLED, HEADERS } from '@readme/oas-extensions';
import lodashGet from 'lodash/get';
import lodashSet from 'lodash/set';
import lodashGet from 'lodash/get.js';
import lodashSet from 'lodash/set.js';
import { Operation, utils } from 'oas';
import { isRef } from 'oas/rmoas.types';
import removeUndefinedObjects from 'remove-undefined-objects';

import configureSecurity from './lib/configure-security';
import formatStyle from './lib/style-formatting';
import { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils';
import configureSecurity from './lib/configure-security.js';
import formatStyle from './lib/style-formatting/index.js';
import { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js';

const { jsonSchemaTypes, matchesMimeType } = utils;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/configure-security.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AuthForHAR } from './types';
import type { AuthForHAR } from './types.js';
import type { OASDocument, SecuritySchemeObject } from 'oas/rmoas.types';

import { isRef } from 'oas/rmoas.types';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/style-formatting/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { StylizerConfig } from './style-serializer';
import type { StylizerConfig } from './style-serializer.js';
import type { ParameterObject, SchemaObject } from 'oas/rmoas.types';

import qs from 'qs';

import stylize from './style-serializer';
import stylize from './style-serializer.js';

// Certain styles don't support empty values.
function shouldNotStyleEmptyValues(parameter: ParameterObject) {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/style-formatting/style-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function isObject(value: unknown) {

export function encodeDisallowedCharacters(
str: string,
// eslint-disable-next-line @typescript-eslint/default-param-last
{
escape,
returnIfEncoded = false,
Expand All @@ -39,7 +38,7 @@ export function encodeDisallowedCharacters(
isAllowedReserved?: boolean;
returnIfEncoded?: boolean;
} = {},
parse: boolean,
parse?: boolean,
) {
if (typeof str === 'number') {
str = (str as number).toString();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { JSONSchema, SchemaObject } from 'oas/rmoas.types';

import lodashGet from 'lodash/get';
import lodashGet from 'lodash/get.js';

/**
* Determine if a schema `type` is, or contains, a specific discriminator.
Expand Down
2 changes: 1 addition & 1 deletion test/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Oas from 'oas';
import { describe, it, expect } from 'vitest';

import oasToHar from '../src';
import oasToHar from '../src/index.js';

import securityQuirks from './__datasets__/security-quirks.json';
import security from './__datasets__/security.json';
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import toBeAValidHAR from 'jest-expect-har';
import Oas from 'oas';
import { describe, beforeEach, it, expect } from 'vitest';

import oasToHar from '../src';
import oasToHar from '../src/index.js';

import serverVariables from './__datasets__/server-variables.json';

Expand Down
2 changes: 1 addition & 1 deletion test/lib/configure-security.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { OASDocument, SecuritySchemeObject } from 'oas/rmoas.types';

import { describe, it, expect } from 'vitest';

import configureSecurity from '../../src/lib/configure-security';
import configureSecurity from '../../src/lib/configure-security.js';

function createSecurityOAS(scheme: SecuritySchemeObject) {
return {
Expand Down
8 changes: 4 additions & 4 deletions test/lib/style-formatting/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { DataForHAR } from '../../../src';
import type { DataForHAR } from '../../../src/index.js';
import type { Request } from 'har-format';

import toBeAValidHAR from 'jest-expect-har';
import { describe, it, expect } from 'vitest';

import oasToHar from '../../../src';
import oasFixture from '../../__fixtures__/create-oas';
import oasToHar from '../../../src/index.js';
import oasFixture from '../../__fixtures__/create-oas.js';
import {
emptyInput,
undefinedInput,
Expand All @@ -19,7 +19,7 @@ import {
objectNestedObjectOfARidiculiousShape,
objectInputEncoded,
undefinedObjectInput,
} from '../../__fixtures__/style-data';
} from '../../__fixtures__/style-data.js';

expect.extend({ toBeAValidHAR });

Expand Down
8 changes: 4 additions & 4 deletions test/lib/style-formatting/multipart-form-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { DataForHAR } from '../../../src';
import type { DataForHAR } from '../../../src/index.js';
import type { PostDataParams } from 'har-format';

import toBeAValidHAR from 'jest-expect-har';
import { describe, it, expect } from 'vitest';

import oasToHar from '../../../src';
import oasFixture from '../../__fixtures__/create-oas';
import oasToHar from '../../../src/index.js';
import oasFixture from '../../__fixtures__/create-oas.js';
import {
emptyInput,
stringInput,
Expand All @@ -16,7 +16,7 @@
objectNestedObject,
objectNestedObjectOfARidiculiousShape,
objectInputEncoded,
} from '../../__fixtures__/style-data';
} from '../../__fixtures__/style-data.js';

expect.extend({ toBeAValidHAR });

Expand Down Expand Up @@ -257,7 +257,7 @@

// This is supposed to be supported, but the style-serializer library we use does not have
// support. Holding off for now.
it.skip(

Check warning on line 260 in test/lib/style-formatting/multipart-form-data.test.ts

View workflow job for this annotation

GitHub Actions / linting

Disabled test
'should NOT support space delimited multipart/form-data styles for exploded object input',
assertSpaceDelimitedStyle(bodyExplode, { body: { object: objectInput } }, []),
);
Expand Down Expand Up @@ -325,7 +325,7 @@

// This is supposed to be supported, but the style-seralizer library we use does not have
// support. Holding off for now.
it.skip(

Check warning on line 328 in test/lib/style-formatting/multipart-form-data.test.ts

View workflow job for this annotation

GitHub Actions / linting

Disabled test
'should NOT support pipe delimited multipart/form-data styles for exploded object input',
assertPipeDelimitedStyle(bodyExplode, { body: { color: objectInput } }, []),
);
Expand Down
4 changes: 2 additions & 2 deletions test/parameters.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { DataForHAR } from '../src';
import type { DataForHAR } from '../src/index.js';
import type { Request } from 'har-format';
import type { OperationObject } from 'oas/rmoas.types';

import toBeAValidHAR from 'jest-expect-har';
import Oas from 'oas';
import { describe, beforeEach, it, expect } from 'vitest';

import oasToHar from '../src';
import oasToHar from '../src/index.js';

import commonParameters from './__datasets__/common-parameters.json';

Expand Down
2 changes: 1 addition & 1 deletion test/requestBody.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import toBeAValidHAR from 'jest-expect-har';
import Oas from 'oas';
import { describe, it, expect } from 'vitest';

import oasToHar from '../src';
import oasToHar from '../src/index.js';

import deeplyNestedJsonFormats from './__datasets__/deeply-nested-json-formats.json';
import multipartFormDataArrayOfFiles from './__datasets__/multipart-form-data/array-of-files.json';
Expand Down