Skip to content

Commit

Permalink
refactor: classified the store
Browse files Browse the repository at this point in the history
  • Loading branch information
Himenon committed Apr 25, 2021
1 parent 0674443 commit fe8774e
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 128 deletions.
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/Extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const hasQueryParameters = (parameters?: OpenApi.Parameter[]): boolean => {
};

export const generateCodeGeneratorParamsArray = (
store: Store.Type,
store: Store,
converterContext: ConverterContext.Types,
allowOperationIds: string[] | undefined,
): CodeGenerator.Params[] => {
Expand Down
4 changes: 2 additions & 2 deletions src/internal/OpenApiTools/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as TypeNodeContext from "./TypeNodeContext";
export class Parser {
private currentPoint: string;
private convertContext: ConvertContext.Types;
private store: Store.Type;
private store: Store;
private factory: TypeScriptCodeGenerator.Factory.Type;
constructor(
private entryPoint: string,
Expand All @@ -26,7 +26,7 @@ export class Parser {
this.currentPoint = entryPoint;
this.convertContext = ConvertContext.create();
this.factory = TypeScriptCodeGenerator.Factory.create();
this.store = Store.create(this.factory, noReferenceOpenApiSchema);
this.store = new Store(this.factory, noReferenceOpenApiSchema);
this.initialize();
}

Expand Down
4 changes: 2 additions & 2 deletions src/internal/OpenApiTools/TypeNodeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const generatePath = (entryPoint: string, currentPoint: string, referencePath: s
};
};

const calculateReferencePath = (store: Store.Type, base: string, pathArray: string[]): ToTypeNode.ResolveReferencePath => {
const calculateReferencePath = (store: Store, base: string, pathArray: string[]): ToTypeNode.ResolveReferencePath => {
let names: string[] = [];
let unresolvedPaths: string[] = [];
pathArray.reduce((previous, lastPath, index) => {
Expand Down Expand Up @@ -75,7 +75,7 @@ const calculateReferencePath = (store: Store.Type, base: string, pathArray: stri

export const create = (
entryPoint: string,
store: Store.Type,
store: Store,
factory: TypeScriptCodeGenerator.Factory.Type,
converterContext: ConverterContext.Types,
): ToTypeNode.Context => {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/Headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as Schema from "./Schema";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
headers: Record<string, OpenApi.Header | OpenApi.Reference>,
context: ToTypeNode.Context,
Expand Down
4 changes: 2 additions & 2 deletions src/internal/OpenApiTools/components/Operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const generateComment = (operation: OpenApi.Operation): string => {
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parentPath: string,
name: string,
Expand Down Expand Up @@ -131,7 +131,7 @@ export const generateNamespace = (
export const generateStatements = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
requestUri: string,
httpMethod: string, // PUT POST PATCH
Expand Down
8 changes: 4 additions & 4 deletions src/internal/OpenApiTools/components/Parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const generateTypeAlias = (
export const generatePropertySignature = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parameter: OpenApi.Parameter | OpenApi.Reference,
context: ToTypeNode.Context,
Expand Down Expand Up @@ -86,7 +86,7 @@ export const generatePropertySignature = (
export const generatePropertySignatures = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parameters: (OpenApi.Parameter | OpenApi.Reference)[],
context: ToTypeNode.Context,
Expand All @@ -100,7 +100,7 @@ export const generatePropertySignatures = (
export const generateInterface = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
name: string,
parameters: [OpenApi.Parameter | OpenApi.Reference],
Expand All @@ -120,7 +120,7 @@ export const generateInterface = (
export const generateAliasInterface = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
name: string,
parameters: (OpenApi.Parameter | OpenApi.Reference)[],
Expand Down
4 changes: 2 additions & 2 deletions src/internal/OpenApiTools/components/Parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as Schema from "./Schema";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parameters: Record<string, OpenApi.Parameter | OpenApi.Reference>,
context: ToTypeNode.Context,
Expand Down Expand Up @@ -71,7 +71,7 @@ export const generateNamespace = (
export const generateNamespaceWithList = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parameters: (OpenApi.Parameter | OpenApi.Reference)[],
context: ToTypeNode.Context,
Expand Down
4 changes: 2 additions & 2 deletions src/internal/OpenApiTools/components/PathItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as Servers from "./Servers";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parentPath: string,
name: string,
Expand Down Expand Up @@ -60,7 +60,7 @@ export const generateNamespace = (
export const generateStatements = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
requestUri: string,
pathItem: OpenApi.PathItem,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/PathItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as Reference from "./Reference";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
pathItems: Record<string, OpenApi.PathItem | OpenApi.Reference>,
context: ToTypeNode.Context,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/RequestBodies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as RequestBody from "./RequestBody";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
requestBodies: Record<string, OpenApi.RequestBody | OpenApi.Reference>,
context: ToTypeNode.Context,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/RequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const generateInterface = (
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parentName: string,
name: string,
Expand Down
6 changes: 3 additions & 3 deletions src/internal/OpenApiTools/components/Response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type { OpenApi } from "../../../types";
import { Factory } from "../../TsGenerator";
import * as ConverterContext from "../ConverterContext";
import * as Name from "../Name";
import { Store } from "../store";
import type { Store } from "../store";
import * as ToTypeNode from "../toTypeNode";
import * as Header from "./Header";
import * as MediaType from "./MediaType";

export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parentPath: string,
name: string,
Expand Down Expand Up @@ -63,7 +63,7 @@ export const generateNamespace = (
export const generateReferenceNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parentPath: string,
nameWithStatusCode: string,
Expand Down
6 changes: 3 additions & 3 deletions src/internal/OpenApiTools/components/Responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as Response from "./Response";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
responses: Record<string, OpenApi.Response | OpenApi.Reference>,
context: ToTypeNode.Context,
Expand Down Expand Up @@ -57,7 +57,7 @@ export const generateNamespace = (
export const generateNamespaceWithStatusCode = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
parentPath: string,
responses: OpenApi.Responses,
Expand Down Expand Up @@ -122,7 +122,7 @@ export const generateNamespaceWithStatusCode = (
export const generateInterfacesWithStatusCode = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
operationId: string,
responses: OpenApi.Responses,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const generateMultiTypeAlias = (
export const addSchema = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
targetPoint: string,
declarationName: string,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/Schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const createNullableTypeNode = (factory: Factory.Type, schema: OpenApi.Schema) =
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
schemas: Record<string, OpenApi.Schema | OpenApi.Reference>,
context: ToTypeNode.Context,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/components/SecuritySchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as SecuritySchema from "./SecuritySchema";
export const generateNamespace = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
requestBodies: Record<string, OpenApi.SecuritySchema | OpenApi.Reference>,
): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/OpenApiTools/paths/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as ToTypeNode from "../toTypeNode";
export const generateStatements = (
entryPoint: string,
currentPoint: string,
store: Store.Type,
store: Store,
factory: Factory.Type,
paths: OpenApi.Paths,
context: ToTypeNode.Context,
Expand Down
Loading

0 comments on commit fe8774e

Please sign in to comment.