Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function protocolGen(host: Host) {
const debug = await host.GetValue('debug') || false;
try {
// get the code model from the core
const session = await startSession(host, codeModelSchema);
const namespace = await session.getValue('namespace');
const operations = await generateOperations(session);
// output the model to the pipeline. this must happen after all model
// updates are complete and before any source files are written.
host.WriteFile('code-model-v4.yaml', serialize(session.model), undefined, 'code-model-v4');
for (const op of values(operations)) {
host.WriteFile(`internal/${namespace}/${op.name.toLowerCase()}.go`, op.content, undefined, 'source-file-go');
}
const enums = await generateEnums(session);
if (enums.length > 0) {
host.WriteFile(`internal/${namespace}/enums.go`, enums, undefined, 'source-file-go');
}
const models = await generateModels(session);
host.WriteFile(`internal/${namespace}/models.go`, models, undefined, 'source-file-go');
const timeHelpers = await generateTimeHelpers(session);
for (const helper of values(timeHelpers)) {
host.WriteFile(`internal/${namespace}/${helper.name.toLowerCase()}.go`, helper.content, undefined, 'source-file-go');
export async function protocolGen(host: Host) {
const debug = await host.GetValue('debug') || false;
try {
// get the code model from the core
const session = await startSession(host, codeModelSchema);
const operations = await generateOperations(session);
let filePrefix = await session.getValue('file-prefix', '');
// if a file prefix was specified, ensure it's properly snaked
if (filePrefix.length > 0 && filePrefix[filePrefix.length - 1] !== '_') {
filePrefix += '_';
}
// output the model to the pipeline. this must happen after all model
// updates are complete and before any source files are written.
host.WriteFile('code-model-v4.yaml', serialize(session.model), undefined, 'code-model-v4');
for (const op of values(operations)) {
host.WriteFile(`${filePrefix}${op.name.toLowerCase()}.swift`, op.content, undefined, 'source-file-swift');
}
const enums = await generateEnums(session);
if (enums.length > 0) {
host.WriteFile(`${filePrefix}enums.swift`, enums, undefined, 'source-file-swift');
}
const models = await generateModels(session);
host.WriteFile(`${filePrefix}models.swift`, models, undefined, 'source-file-swift');
const client = await generateClient(session);
host.WriteFile(`${filePrefix}client.swift`, client, undefined, 'source-file-swift');