Skip to content

Commit

Permalink
Merge pull request #84 from nextcloud/feat/openapitype/better-error-m…
Browse files Browse the repository at this point in the history
…essages

feat(OpenApiType): Show better error messages for unsupported types
  • Loading branch information
nickvergessen authored Mar 25, 2024
2 parents 1d8b0ee + d599766 commit 7ab8029
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 7ab8029

Please sign in to comment.