Skip to content

Commit

Permalink
fix: Allow more specific object keys
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Nov 12, 2024
1 parent b8b55cc commit c5e81e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/OpenApiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ public static function resolve(string $context, array $definitions, ParamTagValu
}

if ($node instanceof GenericTypeNode && $node->type->name === 'array' && count($node->genericTypes) === 2 && $node->genericTypes[0] instanceof IdentifierTypeNode) {
if ($node->genericTypes[0]->name === 'string') {
if (in_array($node->genericTypes[0]->name, ['string', 'lowercase-string', 'non-empty-string', 'non-empty-lowercase-string'], true)) {
return new OpenApiType(
context: $context,
type: 'object',
additionalProperties: self::resolve($context . ': additionalProperties', $definitions, $node->genericTypes[1]),
);
}

Logger::panic($context, "JSON objects can only be indexed by 'string' but got '" . $node->genericTypes[0]->name . "'");
Logger::panic($context, "JSON objects can only be indexed by 'string', 'lowercase-string', 'non-empty-string' or 'non-empty-lowercase-string' but got '" . $node->genericTypes[0]->name . "'");
}

if ($node instanceof GenericTypeNode && $node->type->name == 'int' && count($node->genericTypes) == 2) {
Expand Down

0 comments on commit c5e81e9

Please sign in to comment.