UNPKG

@veecode-platform/safira-cli

Version:

Generate a microservice project from your spec.

42 lines (41 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const core_1 = require("@oclif/core"); const color_1 = require("@oclif/color"); const validate_spec_1 = require("../../openapi/validate-spec"); const safiraColors = tslib_1.__importStar(require("../../colors.json")); class OpenapiValidate extends core_1.Command { async run() { core_1.CliUx.ux.action.start("validating..."); const { args, flags } = await this.parse(OpenapiValidate); try { const result = validate_spec_1.OpenapiValidator.instance.validate(args["file-path"]); core_1.CliUx.ux.action.stop("done"); if (result.valid) { const neonGreen = color_1.color.hex(safiraColors["neon-green"]); this.log(neonGreen("success")); } else { this.log(color_1.color.red(result.errors.join("\n"))); } } catch (error) { core_1.CliUx.ux.action.stop("failed"); this.log(color_1.color.red(error)); } } } exports.default = OpenapiValidate; OpenapiValidate.description = "Validates your openapi file.Supports json or yaml file."; OpenapiValidate.examples = [ "<%= config.bin %> <%= command.id %>", "<%= config.bin %> <%= command.id %> ./openapi-swagger.json", "<%= config.bin %> <%= command.id %> ./openapi-swagger.yaml", ]; OpenapiValidate.flags = { help: core_1.Flags.help({}), }; OpenapiValidate.args = [ { name: "file-path", required: false, description: "Openapi template file location", default: "./openapi-swagger.yaml" }, ];