mirror of
https://github.com/LukeHagar/varsity.git
synced 2025-12-06 21:07:44 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1c9d24e31 | ||
|
|
e33cc19f5f |
@@ -46,11 +46,11 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/luke/varsity.git"
|
"url": "https://github.com/LukeHagar/varsity"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/luke/varsity#readme",
|
"homepage": "https://github.com/LukeHagar/varsity#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/luke/varsity/issues"
|
"url": "https://github.com/LukeHagar/varsity/issues"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"index.ts",
|
"index.ts",
|
||||||
|
|||||||
25
src/cli.ts
25
src/cli.ts
@@ -50,6 +50,12 @@ program
|
|||||||
log.setVerbose(options.verbose);
|
log.setVerbose(options.verbose);
|
||||||
log.setShowProgress(!options.noProgress);
|
log.setShowProgress(!options.noProgress);
|
||||||
log.setUseColors(!options.noColors);
|
log.setUseColors(!options.noColors);
|
||||||
|
if (options.verbose) {
|
||||||
|
log.setLevel("INFO");
|
||||||
|
}
|
||||||
|
if (options.verbose) {
|
||||||
|
log.setLevel("INFO");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const validationOptions: ValidationOptions = {
|
const validationOptions: ValidationOptions = {
|
||||||
strict: options.strict,
|
strict: options.strict,
|
||||||
@@ -181,6 +187,19 @@ program
|
|||||||
console.log(
|
console.log(
|
||||||
` Warnings: ${summary.validationResults.warnings}`
|
` Warnings: ${summary.validationResults.warnings}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Suggest recursive validation if references are found but endpoints are 0
|
||||||
|
if (
|
||||||
|
summary.referenceAnalysis.totalReferences > 0 &&
|
||||||
|
summary.endpoints === 0
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
"\n💡 Tip: This specification contains references that may not be fully analyzed."
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
" Use --recursive flag to validate all referenced schemas and get complete endpoint counts."
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fallback to basic info if summary generation fails
|
// Fallback to basic info if summary generation fails
|
||||||
console.log(`Version: ${validationResult.version}`);
|
console.log(`Version: ${validationResult.version}`);
|
||||||
@@ -278,6 +297,9 @@ program
|
|||||||
log.setVerbose(options.verbose);
|
log.setVerbose(options.verbose);
|
||||||
log.setShowProgress(!options.noProgress);
|
log.setShowProgress(!options.noProgress);
|
||||||
log.setUseColors(!options.noColors);
|
log.setUseColors(!options.noColors);
|
||||||
|
if (options.verbose) {
|
||||||
|
log.setLevel("INFO");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const parsed = await parse(source);
|
const parsed = await parse(source);
|
||||||
|
|
||||||
@@ -413,6 +435,9 @@ program
|
|||||||
log.setVerbose(options.verbose);
|
log.setVerbose(options.verbose);
|
||||||
log.setShowProgress(!options.noProgress);
|
log.setShowProgress(!options.noProgress);
|
||||||
log.setUseColors(!options.noColors);
|
log.setUseColors(!options.noColors);
|
||||||
|
if (options.verbose) {
|
||||||
|
log.setLevel("INFO");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const validationOptions: ValidationOptions = {
|
const validationOptions: ValidationOptions = {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class Logger {
|
|||||||
|
|
||||||
constructor(config: Partial<LoggerConfig> = {}) {
|
constructor(config: Partial<LoggerConfig> = {}) {
|
||||||
this.config = {
|
this.config = {
|
||||||
level: "INFO",
|
level: "WARN",
|
||||||
verbose: false,
|
verbose: false,
|
||||||
showTimestamps: true,
|
showTimestamps: true,
|
||||||
showProgress: true,
|
showProgress: true,
|
||||||
|
|||||||
@@ -139,10 +139,24 @@ export const analyzeSpecification = (
|
|||||||
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
||||||
if (typeof pathItem === "object" && pathItem !== null) {
|
if (typeof pathItem === "object" && pathItem !== null) {
|
||||||
for (const [method, operation] of Object.entries(pathItem)) {
|
for (const [method, operation] of Object.entries(pathItem)) {
|
||||||
|
// Check if this is a valid HTTP method and has operation properties
|
||||||
if (
|
if (
|
||||||
typeof operation === "object" &&
|
typeof operation === "object" &&
|
||||||
operation !== null &&
|
operation !== null &&
|
||||||
"responses" in operation
|
[
|
||||||
|
"get",
|
||||||
|
"post",
|
||||||
|
"put",
|
||||||
|
"delete",
|
||||||
|
"patch",
|
||||||
|
"head",
|
||||||
|
"options",
|
||||||
|
"trace",
|
||||||
|
].includes(method.toLowerCase()) &&
|
||||||
|
("responses" in operation ||
|
||||||
|
"operationId" in operation ||
|
||||||
|
"summary" in operation ||
|
||||||
|
"description" in operation)
|
||||||
) {
|
) {
|
||||||
endpointCount++;
|
endpointCount++;
|
||||||
methods.add(method.toUpperCase());
|
methods.add(method.toUpperCase());
|
||||||
|
|||||||
Reference in New Issue
Block a user