generated from Himenon/template-js
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: remove v3 directory * fix: package json path
- Loading branch information
Showing
60 changed files
with
231 additions
and
233 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/Header.ts → src/Converter/components/Header.ts
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
4 changes: 2 additions & 2 deletions
4
src/Converter/v3/components/Headers.ts → src/Converter/components/Headers.ts
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
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/MediaType.ts → src/Converter/components/MediaType.ts
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
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/Parameter.ts → src/Converter/components/Parameter.ts
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
4 changes: 2 additions & 2 deletions
4
src/Converter/v3/components/Parameters.ts → src/Converter/components/Parameters.ts
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
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/PathItem.ts → src/Converter/components/PathItem.ts
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
4 changes: 2 additions & 2 deletions
4
src/Converter/v3/components/PathItems.ts → src/Converter/components/PathItems.ts
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
6 changes: 3 additions & 3 deletions
6
src/Converter/v3/components/Reference.ts → src/Converter/components/Reference.ts
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
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/RequestBodies.ts → src/Converter/components/RequestBodies.ts
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
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/RequestBody.ts → src/Converter/components/RequestBody.ts
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
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/components/Response.ts → src/Converter/components/Response.ts
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
4 changes: 2 additions & 2 deletions
4
src/Converter/v3/components/Schema.ts → src/Converter/components/Schema.ts
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
4 changes: 2 additions & 2 deletions
4
src/Converter/v3/components/Schemas.ts → src/Converter/components/Schemas.ts
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
2 changes: 1 addition & 1 deletion
2
...Converter/v3/components/SecuritySchema.ts → src/Converter/components/SecuritySchema.ts
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
4 changes: 2 additions & 2 deletions
4
...onverter/v3/components/SecuritySchemas.ts → src/Converter/components/SecuritySchemas.ts
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1 +1,126 @@ | ||
export * as v3 from "./v3"; | ||
import ts from "typescript"; | ||
|
||
import * as TypeScriptCodeGenerator from "../CodeGenerator"; | ||
import * as CodeGenerator from "./CodeGenerator"; | ||
import * as Comment from "./Comment"; | ||
import * as Headers from "./components/Headers"; | ||
import * as Parameters from "./components/Parameters"; | ||
// import * as PathItems from "./components/PathItems"; | ||
import * as RequestBodies from "./components/RequestBodies"; | ||
import * as Responses from "./components/Responses"; | ||
import * as Schemas from "./components/Schemas"; | ||
import * as ConvertContext from "./ConverterContext"; | ||
import * as Name from "./Name"; | ||
import * as Paths from "./paths"; | ||
import { Store } from "./store"; | ||
import * as TypeNodeContext from "./TypeNodeContext"; | ||
import { CodeGeneratorParams, OpenApi, PickedParameter } from "./types"; | ||
|
||
export { OpenApi, CodeGenerator, CodeGeneratorParams, PickedParameter, Name }; | ||
|
||
export interface Type { | ||
generateLeadingComment: () => string; | ||
createFunction: TypeScriptCodeGenerator.CreateFunction; | ||
codeGeneratorOption: CodeGenerator.Option; | ||
} | ||
|
||
export interface Option { | ||
/** | ||
* It is possible to rewrite the implementation after the type declaration. | ||
*/ | ||
rewriteCodeAfterTypeDeclaration: CodeGenerator.RewriteCodeAfterTypeDeclaration; | ||
/** | ||
* | ||
*/ | ||
codeGeneratorOption: CodeGenerator.Option; | ||
/** | ||
* List of operationId to be used | ||
*/ | ||
allowOperationIds?: string[]; | ||
} | ||
|
||
export const create = (entryPoint: string, rootSchema: OpenApi.Document, noReferenceOpenApiSchema: OpenApi.Document, option: Option): Type => { | ||
const currentPoint = entryPoint; | ||
const converterContext = ConvertContext.create(); | ||
|
||
const createFunction = (context: ts.TransformationContext): ts.Statement[] => { | ||
const factory = TypeScriptCodeGenerator.Factory.create(context); | ||
const store = Store.create(factory, noReferenceOpenApiSchema); | ||
const toTypeNodeContext = TypeNodeContext.create(entryPoint, store, factory, converterContext); | ||
|
||
if (rootSchema.components) { | ||
if (rootSchema.components.schemas) { | ||
Schemas.generateNamespace(entryPoint, currentPoint, store, factory, rootSchema.components.schemas, toTypeNodeContext, converterContext); | ||
} | ||
if (rootSchema.components.headers) { | ||
Headers.generateNamespace(entryPoint, currentPoint, store, factory, rootSchema.components.headers, toTypeNodeContext, converterContext); | ||
} | ||
if (rootSchema.components.responses) { | ||
Responses.generateNamespace( | ||
entryPoint, | ||
currentPoint, | ||
store, | ||
factory, | ||
rootSchema.components.responses, | ||
toTypeNodeContext, | ||
converterContext, | ||
); | ||
} | ||
if (rootSchema.components.parameters) { | ||
Parameters.generateNamespace( | ||
entryPoint, | ||
currentPoint, | ||
store, | ||
factory, | ||
rootSchema.components.parameters, | ||
toTypeNodeContext, | ||
converterContext, | ||
); | ||
} | ||
if (rootSchema.components.requestBodies) { | ||
RequestBodies.generateNamespace( | ||
entryPoint, | ||
currentPoint, | ||
store, | ||
factory, | ||
rootSchema.components.requestBodies, | ||
toTypeNodeContext, | ||
converterContext, | ||
); | ||
} | ||
// if (rootSchema.components.securitySchemes) { | ||
// SecuritySchemas.generateNamespace(entryPoint, currentPoint, store, factory, rootSchema.components.securitySchemes); | ||
// } | ||
// if (rootSchema.components.pathItems) { | ||
// PathItems.generateNamespace(entryPoint, currentPoint, store, factory, rootSchema.components.pathItems, toTypeNodeContext); | ||
// } | ||
// TODO Feature Development | ||
// if (rootSchema.components.links) { | ||
// statements.push(Links.generateNamespace(entryPoint, currentPoint, factory, rootSchema.components.links)); | ||
// } | ||
|
||
// TODO Feature Development | ||
// if (rootSchema.components.callbacks) { | ||
// statements.push(Callbacks.generateNamespace(entryPoint, currentPoint, factory, rootSchema.components.callbacks)); | ||
// } | ||
} | ||
if (rootSchema.paths) { | ||
Paths.generateStatements(entryPoint, currentPoint, store, factory, rootSchema.paths, toTypeNodeContext, converterContext); | ||
CodeGenerator.generateApiClientCode( | ||
store, | ||
context, | ||
converterContext, | ||
option.rewriteCodeAfterTypeDeclaration, | ||
option.allowOperationIds, | ||
option.codeGeneratorOption, | ||
); | ||
} | ||
return store.getRootStatements(); | ||
}; | ||
|
||
return { | ||
createFunction, | ||
generateLeadingComment: () => Comment.generateLeading(rootSchema), | ||
codeGeneratorOption: option.codeGeneratorOption, | ||
}; | ||
}; |
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/Converter/v3/store/Operation.ts → src/Converter/store/Operation.ts
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.