Skip to content

Commit a105a28

Browse files
committed
Remove jsonSpec as a global variable
This makes it easier to spot functions that use it.
1 parent 450c102 commit a105a28

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

compiler/src/compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export default class Compiler {
5555

5656
generateModel (): this {
5757
this.jsonSpec = buildJsonSpec()
58-
const endpoints = compileEndpoints()
59-
this.model = compileSpecification(endpoints, this.specsFolder, this.outputFolder)
58+
const endpoints = compileEndpoints(this.jsonSpec)
59+
this.model = compileSpecification(this.jsonSpec, endpoints, this.specsFolder, this.outputFolder)
6060
return this
6161
}
6262

compiler/src/model/build-model.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
TypeAliasDeclaration
3333
} from 'ts-morph'
3434
import * as model from './metamodel'
35-
import buildJsonSpec from './json-spec'
35+
import { JsonSpec } from './json-spec'
3636
import {
3737
assert,
3838
customTypes,
@@ -57,9 +57,7 @@ import {
5757
mediaTypeToStringArray
5858
} from './utils'
5959

60-
const jsonSpec = buildJsonSpec()
61-
62-
export function compileEndpoints (): Record<string, model.Endpoint> {
60+
export function compileEndpoints (jsonSpec: Map<string, JsonSpec>): Record<string, model.Endpoint> {
6361
// Create endpoints and merge them with
6462
// the recorded mappings if present.
6563
const map = {}
@@ -92,7 +90,7 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
9290
return map
9391
}
9492

95-
export function compileSpecification (endpointMappings: Record<string, model.Endpoint>, specsFolder: string, outputFolder: string): model.Model {
93+
export function compileSpecification (jsonSpec: Map<string, JsonSpec>, endpointMappings: Record<string, model.Endpoint>, specsFolder: string, outputFolder: string): model.Model {
9694
const tsConfigFilePath = join(specsFolder, 'tsconfig.json')
9795
const project = new Project({ tsConfigFilePath })
9896

0 commit comments

Comments
 (0)