Skip to content

Commit

Permalink
Merge pull request #428 from xuorig/use-nimma-config
Browse files Browse the repository at this point in the history
Support for `useNimma`?
  • Loading branch information
P0lip authored Jan 26, 2021
2 parents 488e04d + 43f22b9 commit f257268
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
description: |
The name of the event that triggered the workflow
default: ${{ github.event_name }}
use_nimma:
required: false
description: Use the experimental JSON Path engine
default: 'false'
runs:
using: docker
image: Dockerfile
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const Config = D.type({
INPUT_FILE_GLOB: D.string,
INPUT_EVENT_NAME: D.string,
INPUT_SPECTRAL_RULESET: D.string,
INPUT_USE_NIMMA: D.bool,
});

export type Config = D.TypeOf<typeof Config>;
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import * as path from 'path';
const CHECK_NAME = 'Lint';
const traverseTask = array.traverse(T.task);

const createSpectralAnnotations = (ruleset: string, parsed: FileWithContent[], basePath: string) =>
const createSpectralAnnotations = (ruleset: string, parsed: FileWithContent[], basePath: string, useNimma: boolean) =>
pipe(
createSpectral(ruleset),
createSpectral(ruleset, useNimma),
TE.chain(spectral => {
const spectralRuns = parsed.map(v =>
pipe(
Expand Down Expand Up @@ -133,7 +133,7 @@ const program = pipe(
),
TE.bind('fileContents', ({ config }) => readFilesToAnalyze(config.INPUT_FILE_GLOB, config.GITHUB_WORKSPACE)),
TE.bind('annotations', ({ fileContents, config }) =>
createSpectralAnnotations(config.INPUT_SPECTRAL_RULESET, fileContents, config.GITHUB_WORKSPACE)
createSpectralAnnotations(config.INPUT_SPECTRAL_RULESET, fileContents, config.GITHUB_WORKSPACE, config.INPUT_USE_NIMMA)
),
TE.bind('checkResponse', ({ octokit, check, repositoryInfo, annotations }) =>
updateGithubCheck(
Expand Down
4 changes: 2 additions & 2 deletions src/spectral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ const retrieveSpectralPackageVersion = (): IOEither.IOEither<Error, string> =>
return String(x.version);
}, E.toError);

export const createSpectral = (rulesetPath: string) =>
export const createSpectral = (rulesetPath: string, useNimma: boolean) =>
pipe(
TE.fromIOEither(retrieveSpectralPackageVersion()),
TE.chain(spectralPackageVersion =>
TE.tryCatch(async () => {
info(`Running Spectral v${spectralPackageVersion}`);

const spectral = new Spectral({ resolver: httpAndFileResolver });
const spectral = new Spectral({ resolver: httpAndFileResolver, useNimma: useNimma });
spectral.registerFormat('oas2', isOpenApiv2);
spectral.registerFormat('oas3', isOpenApiv3);
spectral.registerFormat('json-schema', isJSONSchema);
Expand Down

0 comments on commit f257268

Please sign in to comment.