mirror of
https://github.com/LukeHagar/varsity.git
synced 2025-12-06 04:22:00 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab0a642cdf | ||
|
|
b1c9d24e31 | ||
|
|
e33cc19f5f |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "varsity",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "Comprehensive OpenAPI parsing and validation library",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
@@ -46,11 +46,11 @@
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"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": {
|
||||
"url": "https://github.com/luke/varsity/issues"
|
||||
"url": "https://github.com/LukeHagar/varsity/issues"
|
||||
},
|
||||
"files": [
|
||||
"index.ts",
|
||||
|
||||
25
src/cli.ts
25
src/cli.ts
@@ -50,6 +50,12 @@ program
|
||||
log.setVerbose(options.verbose);
|
||||
log.setShowProgress(!options.noProgress);
|
||||
log.setUseColors(!options.noColors);
|
||||
if (options.verbose) {
|
||||
log.setLevel("INFO");
|
||||
}
|
||||
if (options.verbose) {
|
||||
log.setLevel("INFO");
|
||||
}
|
||||
try {
|
||||
const validationOptions: ValidationOptions = {
|
||||
strict: options.strict,
|
||||
@@ -181,6 +187,19 @@ program
|
||||
console.log(
|
||||
` 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) {
|
||||
// Fallback to basic info if summary generation fails
|
||||
console.log(`Version: ${validationResult.version}`);
|
||||
@@ -278,6 +297,9 @@ program
|
||||
log.setVerbose(options.verbose);
|
||||
log.setShowProgress(!options.noProgress);
|
||||
log.setUseColors(!options.noColors);
|
||||
if (options.verbose) {
|
||||
log.setLevel("INFO");
|
||||
}
|
||||
try {
|
||||
const parsed = await parse(source);
|
||||
|
||||
@@ -413,6 +435,9 @@ program
|
||||
log.setVerbose(options.verbose);
|
||||
log.setShowProgress(!options.noProgress);
|
||||
log.setUseColors(!options.noColors);
|
||||
if (options.verbose) {
|
||||
log.setLevel("INFO");
|
||||
}
|
||||
|
||||
try {
|
||||
const validationOptions: ValidationOptions = {
|
||||
|
||||
@@ -54,7 +54,7 @@ export class Logger {
|
||||
|
||||
constructor(config: Partial<LoggerConfig> = {}) {
|
||||
this.config = {
|
||||
level: "INFO",
|
||||
level: "WARN",
|
||||
verbose: false,
|
||||
showTimestamps: true,
|
||||
showProgress: true,
|
||||
|
||||
@@ -139,10 +139,24 @@ export const analyzeSpecification = (
|
||||
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
||||
if (typeof pathItem === "object" && pathItem !== null) {
|
||||
for (const [method, operation] of Object.entries(pathItem)) {
|
||||
// Check if this is a valid HTTP method and has operation properties
|
||||
if (
|
||||
typeof operation === "object" &&
|
||||
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++;
|
||||
methods.add(method.toUpperCase());
|
||||
|
||||
Reference in New Issue
Block a user