Skip to content

Commit

Permalink
fix(msw): generate correctly multi files with non specification file
Browse files Browse the repository at this point in the history
  • Loading branch information
anymaniax committed Sep 23, 2022
1 parent 65fcc68 commit 968fb99
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 42 deletions.
6 changes: 1 addition & 5 deletions src/core/generators/api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { PathItemObject } from 'openapi3-ts';
import { ContextSpecs, NormalizedOutputOptions } from '../../types';
import {
GeneratorApiResponse,
GeneratorSchema,
GeneratorVerbsOptions,
} from '../../types/generator';
import { GeneratorApiResponse, GeneratorSchema } from '../../types/generator';
import { asyncReduce } from '../../utils/async-reduce';
import { isReference } from '../../utils/is';
import { getRoute } from '../getters/route';
Expand Down
31 changes: 0 additions & 31 deletions src/core/getters/schema.ts

This file was deleted.

15 changes: 9 additions & 6 deletions src/core/resolvers/value.mock.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import get from 'lodash.get';
import { SchemaObject } from 'openapi3-ts';
import { ContextSpecs, MockOptions } from '../../types';
import { GeneratorImport } from '../../types/generator';
import { MockDefinition, MockSchemaObject } from '../../types/mocks';
import { isReference } from '../../utils/is';
import { getRefInfo } from '../getters/ref';
import { getMockScalar } from '../getters/scalar.mock';
import { getSchema } from '../getters/schema';

const isRegex = (key: string) => key[0] === '/' && key[key.length - 1] === '/';

Expand Down Expand Up @@ -64,13 +64,16 @@ export const resolveMockValue = ({
imports: GeneratorImport[];
}): MockDefinition & { type?: string } => {
if (isReference(schema)) {
const { name, specKey = context.specKey } = getRefInfo(
schema.$ref,
context,
);
const {
name,
specKey = context.specKey,
refPaths,
} = getRefInfo(schema.$ref, context);

const schemaRef = get(context.specs[specKey], refPaths);

const newSchema = {
...getSchema(name, context, specKey),
...schemaRef,
name,
path: schema.path,
isRef: true,
Expand Down

0 comments on commit 968fb99

Please sign in to comment.