-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DependencyInjection][Routing] Add JSON schema for validating and autocompleting YAML config files #61282
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
Open
nicolas-grekas
wants to merge
1
commit into
symfony:7.4
Choose a base branch
from
nicolas-grekas:json-schema
base: 7.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[DependencyInjection][Routing] Add JSON schema for validating and autocompleting YAML config files #61282
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
154 changes: 154 additions & 0 deletions
154
...Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Symfony Parameters and Services Configuration", | ||
"description": "Defines application parameters and services, including environment-specific conditionals.", | ||
"type": "object", | ||
"properties": { | ||
"parameters": { | ||
"type": "object", | ||
"description": "Defines application-wide parameters.", | ||
"patternProperties": { | ||
"^.*$": { "$ref": "#/$defs/parameterValue" } | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"services": { | ||
"type": "object", | ||
"description": "Defines your application services.", | ||
"properties": { | ||
"_defaults": { | ||
"$ref": "#/$defs/serviceDefaults" | ||
}, | ||
"_instanceof": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^.+$": { "$ref": "#/$defs/serviceDefaults" } | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"patternProperties": { | ||
"^[a-zA-Z0-9_\\\\.]+$": { | ||
"oneOf": [ | ||
{ "$ref": "#/$defs/serviceDefinition" }, | ||
{ "type": "null" }, | ||
{ "type": "string" } | ||
] | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"patternProperties": { | ||
"^when@.+$": { | ||
"$ref": "#", | ||
"description": "A container for parameters and services that are only loaded in a specific environment." | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"$defs": { | ||
"parameterValue": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "number" }, | ||
{ "type": "boolean" }, | ||
{ "type": "array" }, | ||
{ "type": "object" }, | ||
{ "type": "null" } | ||
] | ||
}, | ||
"serviceDefinition": { | ||
"type": "object", | ||
"properties": { | ||
"class": { "type": "string" }, | ||
"arguments": { "type": "array", "items": { "$ref": "#/$defs/parameterValue" } }, | ||
"tags": { | ||
"type": "array", | ||
"items": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ | ||
"type": "object", | ||
"properties": { "name": { "type": "string" } }, | ||
"required": ["name"], | ||
"additionalProperties": true | ||
} | ||
] | ||
} | ||
}, | ||
"calls": { | ||
"type": "array", | ||
"items": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": [{ "type": "string" }], | ||
"additionalItems": { "$ref": "#/$defs/parameterValue" } | ||
} | ||
}, | ||
"factory": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ | ||
"type": "array", | ||
"items": [ { "type": "string" }, { "type": "string" } ], | ||
"minItems": 2, | ||
"maxItems": 2 | ||
} | ||
] | ||
}, | ||
"properties": { "type": "object" }, | ||
"configurator": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ | ||
"type": "array", | ||
"items": [ { "type": "string" }, { "type": "string" } ], | ||
"minItems": 2, | ||
"maxItems": 2 | ||
} | ||
] | ||
}, | ||
"public": { "type": "boolean" }, | ||
"shared": { "type": "boolean" }, | ||
"abstract": { "type": "boolean" }, | ||
"parent": { "type": "string" }, | ||
"alias": { "type": "string" }, | ||
"autowire": { "type": "boolean" }, | ||
"autoconfigure": { "type": "boolean" }, | ||
"deprecated": { | ||
"oneOf": [ | ||
{ "type": "boolean" }, | ||
{ "type": "string" }, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"message": { "type": "string" } | ||
}, | ||
"required": ["message"] | ||
} | ||
] | ||
}, | ||
"decorates": { "type": "string" }, | ||
"decoration_inner_name": { "type": "string" }, | ||
"decoration_priority": { "type": "integer" } | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"serviceDefaults": { | ||
"type": "object", | ||
"properties": { | ||
"autowire": { "type": "boolean" }, | ||
"autoconfigure": { "type": "boolean" }, | ||
"public": { "type": "boolean" }, | ||
"bind": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$": { "$ref": "#/$defs/parameterValue" } | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Symfony Routing Configuration", | ||
"description": "Defines the application's URL routes, including imports and environment-specific conditionals.", | ||
"type": "object", | ||
"patternProperties": { | ||
"^[a-zA-Z0-9_.-]+$": { | ||
"oneOf": [ | ||
{ "$ref": "#/$defs/routeDefinition" }, | ||
{ "$ref": "#/$defs/routeImport" } | ||
] | ||
}, | ||
"^when@.+$": { | ||
"$ref": "#", | ||
"description": "A container for routes that are only loaded in a specific environment (e.g., 'when@dev')." | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"$defs": { | ||
"routeDefinition": { | ||
"type": "object", | ||
"properties": { | ||
"path": { | ||
"type": "string", | ||
"description": "The URL path for this route, which can contain parameters like /{id}." | ||
}, | ||
"controller": { | ||
"type": "string", | ||
"description": "The controller that handles the request, e.g., 'App\\Controller\\BlogController::show'." | ||
}, | ||
"methods": { | ||
"description": "The HTTP method(s) this route matches.", | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "array", "items": { "type": "string" } } | ||
] | ||
}, | ||
"requirements": { | ||
"type": "object", | ||
"description": "Regular expression constraints for path parameters.", | ||
"patternProperties": { "^.+$": { "type": "string" } } | ||
}, | ||
"defaults": { "type": "object" }, | ||
"options": { "type": "object" }, | ||
"host": { "type": "string" }, | ||
"schemes": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "array", "items": { "type": "string" } } | ||
] | ||
}, | ||
"condition": { "type": "string" }, | ||
"priority": { "type": "integer" }, | ||
"locale": { "type": "string" }, | ||
"format": { "type": "string" }, | ||
"utf8": { "type": "boolean" } | ||
}, | ||
"required": ["path"], | ||
"additionalProperties": false | ||
}, | ||
"routeImport": { | ||
"type": "object", | ||
"properties": { | ||
"resource": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"path": { "type": "string" }, | ||
"namespace": { "type": "string" } | ||
}, | ||
"required": ["path"], | ||
"additionalProperties": false | ||
} | ||
], | ||
"description": "Path to the resource (as a string) or an object with a 'path' and 'namespace'." | ||
}, | ||
"type": { | ||
"type": "string", | ||
"description": "The type of the resource (e.g., 'attribute', 'annotation', 'yaml')." | ||
}, | ||
"prefix": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "object", "patternProperties": { "^.+$": { "type": "string" } } } | ||
], | ||
"description": "A URL prefix to apply to all routes from the imported resource." | ||
}, | ||
"name_prefix": { | ||
"type": "string", | ||
"description": "A name prefix to apply to all routes from the imported resource." | ||
}, | ||
"requirements": { "type": "object" }, | ||
"defaults": { "type": "object" }, | ||
"options": { "type": "object" }, | ||
"host": { "type": "string" }, | ||
"schemes": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "array", "items": { "type": "string" } } | ||
] | ||
}, | ||
"condition": { "type": "string" }, | ||
"priority": { "type": "integer" }, | ||
"locale": { "type": "string" }, | ||
"format": { "type": "string" }, | ||
"utf8": { "type": "boolean" } | ||
}, | ||
"required": ["resource"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version number was never updated for the xsd file name. I think a shorter file name would be better as it needs to be in all the Yaml files that use it.
# $schema: ../../vendor/symfony/dependency-injection/Loader/schema/dic/services/services-1.0.schema.json
Maybe:
# $schema: ../../vendor/symfony/dependency-injection/Loader/schema/services.schema.json
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could also host those files on symfony.com so that the link could always be absolute?