Skip to content

Commit 5c6f59c

Browse files
author
Artem Parkhomenko
committed
remove redundant deepLookup
1 parent 4e12b64 commit 5c6f59c

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

src/index.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { FSEntity, write } from './utils/fs';
33
import * as path from 'path';
44
import * as $RefParser from 'json-schema-ref-parser';
55
import { pipe } from 'fp-ts/lib/pipeable';
6-
import { array, either, taskEither, option } from 'fp-ts';
6+
import { array, either, taskEither } from 'fp-ts';
77
import { Either, isLeft, toError } from 'fp-ts/lib/Either';
88
import { identity } from 'fp-ts/lib/function';
99
import { reportIfFailed } from './utils/io-ts';
1010
import { TaskEither } from 'fp-ts/lib/TaskEither';
1111
import { sketchParser121 } from './parsers/sketch-121';
12-
import { DeepLookup, ResolveRef, ResolveRefContext } from './utils/ref';
12+
import { ResolveRef, ResolveRefContext } from './utils/ref';
1313
import { Reader } from 'fp-ts/lib/Reader';
1414

1515
export interface Language<A> {
@@ -74,21 +74,7 @@ export const generate = <A>(options: GenerateOptions<A>): TaskEither<unknown, vo
7474
either.chain(resolved => reportIfFailed(decoder.decode(resolved))),
7575
);
7676

77-
const deepLookup: DeepLookup = (node: unknown, codec, refCodec) =>
78-
codec.is(node)
79-
? option.some(node)
80-
: refCodec.is(node)
81-
? pipe(
82-
option.fromEither(resolveRef(node.$ref, codec)),
83-
option.alt(() =>
84-
pipe(
85-
option.fromEither(resolveRef(node.$ref, refCodec)),
86-
option.chain(node => deepLookup(node, codec, refCodec)),
87-
),
88-
),
89-
)
90-
: option.none;
91-
await write(out, getUnsafe(options.language({ resolveRef, deepLookup })(specs)));
77+
await write(out, getUnsafe(options.language({ resolveRef })(specs)));
9278

9379
log('Done');
9480
}, identity);

src/language/typescript/2.0/serializers/operation-object.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ export const serializeOperationObject = combineReader(
268268
),
269269
);
270270

271-
console.log(responseType, operation.produces);
272-
273271
return combineEither(
274272
parameters,
275273
serializedResponses,

src/utils/ref.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { isNonEmpty, uniq } from 'fp-ts/lib/Array';
33
import { last, NonEmptyArray } from 'fp-ts/lib/NonEmptyArray';
44
import { Either, left, right } from 'fp-ts/lib/Either';
55
import { Eq, eqString, getStructEq } from 'fp-ts/lib/Eq';
6-
import { Decoder, Type } from 'io-ts';
7-
import { Option } from 'fp-ts/lib/Option';
6+
import { Decoder } from 'io-ts';
87

98
export interface Ref<R extends string = string> {
109
readonly $ref: string;
@@ -100,11 +99,6 @@ export interface ResolveRef {
10099
<A>($ref: string, decoder: Decoder<unknown, A>): Either<Error, A>;
101100
}
102101

103-
export interface DeepLookup {
104-
<A>(node: unknown, codec: Type<A, unknown>, refCodec: Type<{ $ref: string }, unknown>): Option<A>;
105-
}
106-
107102
export interface ResolveRefContext {
108103
readonly resolveRef: ResolveRef;
109-
readonly deepLookup: DeepLookup;
110104
}

0 commit comments

Comments
 (0)