From 84382b076ab3b6cf9e01521f5520cab0ca473477 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 31 Jul 2025 10:28:51 +0200 Subject: [PATCH] [DependencyInjection][Routing] Add JSON schema for validating and autocompleting YAML config files --- .../dic/services/services-1.0.schema.json | 154 ++++++++++++++++++ .../schema/routing/routing-1.0.schema.json | 114 +++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.schema.json create mode 100644 src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.schema.json diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.schema.json b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.schema.json new file mode 100644 index 0000000000000..728246cf52102 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.schema.json @@ -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 + } + } +} diff --git a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.schema.json b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.schema.json new file mode 100644 index 0000000000000..68d9fb7b0cc9a --- /dev/null +++ b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.schema.json @@ -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 + } + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy