Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(OpenApiType): Show better error messages for unsupported types #84

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/OpenApiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public static function resolve(string $context, array $definitions, ParamTagValu
}
return new OpenApiType(type: "array", items: self::resolve($context, $definitions, $node->genericTypes[0]));
}
if ($node instanceof GenericTypeNode && $node->type->name === 'value-of') {
Logger::panic($context, "'value-of' is not supported");
}

if ($node instanceof ArrayShapeNode) {
$properties = [];
Expand Down Expand Up @@ -266,7 +269,11 @@ enum: [(int)$node->constExpr->value],
);
}

Logger::panic($context, "Unable to resolve OpenAPI type for type '" . get_class($node) . "'");
if ($node instanceof ConstTypeNode) {
Logger::panic($context, 'Constants are not supported');
}

Logger::panic($context, "Unable to resolve OpenAPI type:\n" . var_export($node, true) . "\nPlease open an issue at https://github.com/nextcloud/openapi-extractor/issues/new with the error message and a link to your source code.");
}

/**
Expand Down