Fix: Allow definitions/properties named 'enum' or 'const' during ref expansion #850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The validator throws
UnresolvableJsonPointerExceptionwhen schemas contain definitions or properties named 'enum' or 'const' (common in OpenAPI specs). The code unconditionally skipped these properties during reference expansion, treating them as JSON Schema keywords rather than potentially valid property names.Root Cause
SchemaStorage.phpskipped ANY property named 'enum'/'const' in two locations:expandRefs()line 104-107scanForSubschemas()line 210-212This prevented refs inside such definitions from being resolved.
Changes
isSchemaObject()helper to distinguish schema objects (with validation keywords) from pure containers (definitions, properties objects)SCHEMA_KEYWORDSconstant containing 33 JSON Schema keywords organized by categoryExample
This now works:
{ "definitions": { "enum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/enum" } } }While still correctly skipping actual keywords:
{ "type": "string", "enum": ["red", "green", "blue"] }Testing
Added regression test
testDefinitionNamedEnumIsResolved()covering both scenarios.Fixes issue reported at https://github.com/mxr576/oas-validation-issue-on-v6
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/0ad2f84130e8fec8655682532e6d39553054831c/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/29dc0d507e838c4580d018bd8b5cb412474f7ec3/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/xdebug-handler/zipball/9e36aeed4616366d2b690bdce11f71e9178c579a/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/annotations/zipball/253dca476f70808a5aeed3a47cc2cc88c5cab915/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/lexer/zipball/861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/jsonrainbow/json-schema/zipball/68ba7677532803cc0c5900dd5a4d730537f2b2f3/usr/bin/php8.3 -n -c /tmp/c983hR /usr/bin/composer install(http block)https://api.github.com/repos/marc-mabe/php-enum-phpstan/zipball/63d391c16e3a7753bb928f61d1989438ee63eebc/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/marc-mabe/php-enum/zipball/bb426fcdd65c60fb3638ef741e8782508fda7eef/usr/bin/php8.3 -n -c /tmp/c983hR /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1e0cd5370df5dd2e556a36b9c62f62e555870495/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/comparator/zipball/4b3c947888c81708b20fb081bb653a2ba68f989a/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/diff/zipball/98ff311ca519c3aa73ccd3de053bdb377171d7b6/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/exporter/zipball/64cfeaa341951ceb2019d7b98232399d57bb2296/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/8fe7e75986a9d24b4cceae847314035df7703a5a/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/c983hR /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/filesystem/zipball/57c8294ed37d4a055b77057827c67f9558c95c54/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/options-resolver/zipball/74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638/usr/bin/php8.3 -n -c /tmp/c983hR /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/stopwatch/zipball/fb2c199cf302eb207f8c23e7ee174c1c31a5c004/usr/bin/php8.3 -n -c /tmp/jNDR7s /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/string/zipball/5621f039a71a11c87c106c1c598bdcd04a19aeea/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/yaml/zipball/90208e2fc6f68f613eae7ca25a2458a931b1bacc/usr/bin/php8.3 -n -c /tmp/c983hR /usr/bin/composer install(http block)https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68/usr/bin/php8.3 -n -c /tmp/Pc9DfP /usr/bin/composer install --no-interaction(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.