-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add possibility to pass custom resolvers
- Loading branch information
1 parent
cc46e8f
commit 376ef2e
Showing
5 changed files
with
114 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Resolver as SpectralResolver } from '@stoplight/json-ref-resolver'; | ||
import { resolveFile, resolveHttp } from '@stoplight/json-ref-readers'; | ||
|
||
export interface Resolver { | ||
order?: number; | ||
canRead?: boolean | ((input: ResolverInput) => boolean); | ||
read: (input: ResolverInput) => string | Buffer | Promise<string | Buffer>; | ||
} | ||
|
||
export interface ResolverInput { | ||
url: string; | ||
extension: string; | ||
} | ||
|
||
interface ResolverOptions { | ||
resolvers: Array<Resolver>; | ||
} | ||
|
||
export function createResolver(options?: ResolverOptions): SpectralResolver { | ||
return new SpectralResolver({ | ||
resolvers: { | ||
https: { resolve: resolveHttp }, | ||
http: { resolve: resolveHttp }, | ||
file: { resolve: resolveFile }, | ||
}, | ||
}); | ||
} | ||
|
||
export function createFileResolver() { | ||
|
||
} | ||
|
||
export function createHttpResolver() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters