Spaces:
Runtime error

File size: 13,699 Bytes
7a66774
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Symfony Parameters and Services Configuration",
  "description": "Defines application parameters and services, including imports and environment-specific conditionals.",
  "$comment": "Root allows extension namespaces (framework:, doctrine:, etc.) via additionalProperties: true.",
  "type": "object",
  "properties": {
    "imports": {
      "type": "array",
      "description": "Import other configuration resources.",
      "$comment": "YAML examples:\n- { resource: 'services.yaml' }\n- { resource: packages/dev/services.yaml, ignore_errors: true }\n- 'other_file.yaml'",
      "items": {
        "oneOf": [
          { "type": "string" },
          {
            "type": "object",
            "properties": {
              "resource": { "type": "string" },
              "type": { "type": ["string", "null"] },
              "ignore_errors": { "type": "boolean" }
            },
            "required": ["resource"],
            "additionalProperties": false
          }
        ]
      }
    },
    "parameters": {
      "type": "object",
      "description": "Defines application-wide parameters.",
      "$comment": "Values support scalars, arrays and objects.",
      "patternProperties": {
        "^.+$": { "$ref": "#/$defs/parameterValue" }
      },
      "additionalProperties": false
    },
    "services": {
      "type": "object",
      "description": "Defines your application services.",
      "$comment": "Service ids accept multiple shapes: object (full definition), '@alias' string (alias), null (empty definition), prototype (resource/namespace), stack, and short array syntax for arguments.",
      "properties": {
        "_defaults": {
          "$ref": "#/$defs/serviceDefaults"
        },
        "_instanceof": {
          "type": "object",
          "patternProperties": {
            "^.+$": { "$ref": "#/$defs/serviceInstanceof" }
          },
          "additionalProperties": false
        }
      },
      "patternProperties": {
        "^(?:[A-Za-z_\\x7f-\\xff][A-Za-z0-9_\\x7f-\\xff]*\\\\)+[A-Za-z_\\x7f-\\xff][A-Za-z0-9_\\x7f-\\xff]*$": {
          "oneOf": [
            { "$ref": "#/$defs/serviceConcrete" },
            { "$ref": "#/$defs/serviceAliasObject" },
            { "$ref": "#/$defs/servicePrototype" },
            { "$ref": "#/$defs/serviceStack" },
            { "$ref": "#/$defs/serviceShortSyntax" },
            { "type": "null" },
            { "type": "string", "pattern": "^@.+" }
          ],
          "$comment": "FQCN service ids: short array syntax is allowed here."
        },
        "^(?!_).+$": {
          "oneOf": [
            { "$ref": "#/$defs/serviceConcrete" },
            { "$ref": "#/$defs/serviceAliasObject" },
            { "$ref": "#/$defs/servicePrototype" },
            { "$ref": "#/$defs/serviceStack" },
            { "type": "null" },
            { "type": "string", "pattern": "^@.+" }
          ],
          "$comment": "Non-FQCN ids: short array syntax is not allowed."
        }
      },
      "additionalProperties": false
    }
  },
  "patternProperties": {
    "^when@.+$": {
      "$ref": "#",
      "description": "A container for parameters and services that are only loaded in a specific environment."
    }
  },
  "additionalProperties": true,
  "$defs": {
    "parameterValue": {
      "oneOf": [
        { "type": "string" },
        { "type": "number" },
        { "type": "boolean" },
        { "type": "array" },
        { "type": "object" },
        { "type": "null" }
      ]
    },
    "scalarValue": {
      "oneOf": [
        { "type": "string" },
        { "type": "number" },
        { "type": "boolean" },
        { "type": "null" }
      ]
    },
    "fqcn": {
      "type": "string",
      "pattern": "^(?:\\\\)?(?:[A-Za-z_\\\\x7f-\\\\xff][A-Za-z0-9_\\\\x7f-\\\\xff]*\\\\)+[A-Za-z_\\\\x7f-\\\\xff][A-Za-z0-9_\\\\x7f-\\\\xff]*$",
      "$comment": "Fully-qualified class name, optional leading backslash; requires at least one namespace separator."
    },
    "arguments": {
      "$comment": "Arguments can be an array (positional) or a map (named).",
      "oneOf": [
        { "type": "array", "items": { "$ref": "#/$defs/parameterValue" } },
        { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } }
      ]
    },
    "tags": {
      "$comment": "YAML examples:\n- ['kernel.event_subscriber', { name: 'kernel.event_listener', event: 'kernel.request' }, { my_tag: { attr: 1 } }].",
      "type": "array",
      "items": {
        "oneOf": [
          { "type": "string" },
          {
            "type": "object",
            "properties": { "name": { "type": "string" } },
            "required": ["name"],
            "additionalProperties": true
          },
          {
            "type": "object",
            "minProperties": 1,
            "maxProperties": 1,
            "additionalProperties": {
              "type": "object",
              "additionalProperties": { "$ref": "#/$defs/parameterValue" }
            }
          }
        ]
      }
    },
    "calls": {
      "$comment": "YAML examples:\n- ['setFoo', ['@bar'], true]\n- { method: 'setFoo', arguments: ['@bar'], returns_clone: true }\n- { setFoo: ['@bar'] }\n- { setFoo: !returns_clone ['@bar'] } (special YAML tag)",
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "items": [
              { "type": "string" },
              {
                "oneOf": [
                  { "type": "array", "items": { "$ref": "#/$defs/parameterValue" } },
                  { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } }
                ]
              },
              { "type": "boolean" }
            ]
          },
          {
            "type": "object",
            "properties": {
              "method": { "type": "string" },
              "arguments": { "$ref": "#/$defs/arguments" },
              "returns_clone": { "type": "boolean" }
            },
            "required": ["method"],
            "additionalProperties": false
          },
          {
            "type": "object",
            "minProperties": 1,
            "maxProperties": 1,
            "additionalProperties": { "$ref": "#/$defs/arguments" }
          }
        ]
      }
    },
    "deprecation": {
      "$comment": "YamlFileLoader requires an object with 'package' and 'version'.",
      "type": "object",
      "properties": {
        "package": { "type": "string" },
        "version": { "type": "string" },
        "message": { "type": "string" }
      },
      "required": ["package", "version"],
      "additionalProperties": false
    },
    "callable": {
      "$comment": "Either 'Class::method' or ['Class', 'method'].",
      "oneOf": [
        { "type": "string" },
        {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [ { "type": "string" }, { "type": "string" } ]
        }
      ]
    },
    "serviceShortSyntax": {
      "$comment": "Short syntax: service defined as arguments array. YAML example: App\\SomeService: ['@dependency', 'literal', 123]",
      "type": "array",
      "items": { "$ref": "#/$defs/parameterValue" }
    },
    "factoryCallable": {
      "$comment": "Either '@service', 'Class::method', or [classOrService, method]. For ['null', method] the class is resolved from the service class when using 'constructor'.",
      "oneOf": [
        { "type": "string" },
        {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [ { "type": ["string", "null"] }, { "type": "string" } ]
        }
      ]
    },
    "serviceAliasObject": {
      "$comment": "Allowed keys for aliases are only 'alias', 'public', 'deprecated'.",
      "type": "object",
      "properties": {
        "alias": { "type": "string" },
        "public": { "type": "boolean" },
        "deprecated": { "$ref": "#/$defs/deprecation" }
      },
      "required": ["alias"],
      "additionalProperties": false
    },
    "serviceConcrete": {
      "$comment": "'constructor' cannot be used together with 'factory'. If 'from_callable' is used, many other keys are not allowed (see YamlFileLoader).",
      "type": "object",
      "properties": {
        "class": { "type": "string" },
        "file": { "type": "string" },
        "parent": { "type": "string" },
        "shared": { "type": "boolean" },
        "synthetic": { "type": "boolean" },
        "lazy": { "oneOf": [ { "type": "boolean" }, { "$ref": "#/$defs/fqcn" } ] },
        "public": { "type": "boolean" },
        "abstract": { "type": "boolean" },
        "deprecated": { "$ref": "#/$defs/deprecation" },
        "factory": { "$ref": "#/$defs/factoryCallable" },
        "configurator": { "$ref": "#/$defs/callable" },
        "arguments": { "$ref": "#/$defs/arguments" },
        "properties": { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } },
        "calls": { "$ref": "#/$defs/calls" },
        "tags": { "$ref": "#/$defs/tags" },
        "resource_tags": { "$ref": "#/$defs/tags" },
        "decorates": { "type": "string" },
        "decoration_inner_name": { "type": "string" },
        "decoration_priority": { "type": "integer" },
        "decoration_on_invalid": { "oneOf": [ { "enum": ["exception", "ignore"] }, { "type": "null" } ], "$comment": "Use null (without quotes) for NULL_ON_INVALID_REFERENCE." },
        "autowire": { "type": "boolean" },
        "autoconfigure": { "type": "boolean" },
        "bind": { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } },
        "constructor": { "type": "string" },
        "from_callable": { "$ref": "#/$defs/parameterValue", "$comment": "Will be wrapped by factory ['Closure','fromCallable'] and sets lazy=true unless class is 'Closure'." }
      },
      "additionalProperties": false
    },
    "servicePrototype": {
      "$comment": "Prototype definitions register classes by scanning directories. 'namespace' requires 'resource'.",
      "type": "object",
      "properties": {
        "resource": { "type": "string" },
        "namespace": { "type": "string" },
        "exclude": {
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "type": "string" } }
          ]
        },
        "parent": { "type": "string" },
        "shared": { "type": "boolean" },
        "lazy": { "oneOf": [ { "type": "boolean" }, { "$ref": "#/$defs/fqcn" } ] },
        "public": { "type": "boolean" },
        "abstract": { "type": "boolean" },
        "deprecated": { "$ref": "#/$defs/deprecation" },
        "factory": { "$ref": "#/$defs/factoryCallable" },
        "arguments": { "$ref": "#/$defs/arguments" },
        "properties": { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } },
        "configurator": { "$ref": "#/$defs/callable" },
        "calls": { "$ref": "#/$defs/calls" },
        "tags": { "$ref": "#/$defs/tags" },
        "resource_tags": { "$ref": "#/$defs/tags" },
        "autowire": { "type": "boolean" },
        "autoconfigure": { "type": "boolean" },
        "bind": { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } },
        "constructor": { "type": "string" }
      },
      "required": ["resource"],
      "allOf": [
        { "anyOf": [ { "not": { "required": ["namespace"] } }, { "required": ["resource"] } ] }
      ],
      "additionalProperties": false
    },
    "serviceStack": {
      "$comment": "A stack builds a service pipeline from multiple frames.",
      "type": "object",
      "properties": {
        "stack": {
          "type": "array",
          "items": {
            "oneOf": [
              { "$ref": "#/$defs/serviceConcrete" },
              { "$ref": "#/$defs/serviceAliasObject" },
              { "$ref": "#/$defs/servicePrototype" }
            ]
          }
        },
        "public": { "type": "boolean" },
        "deprecated": { "$ref": "#/$defs/deprecation" }
      },
      "required": ["stack"],
      "additionalProperties": false
    },
    "serviceDefaults": {
      "$comment": "Defaults applied to services declared in the current file.",
      "type": "object",
      "properties": {
        "public": { "type": "boolean" },
        "tags": { "$ref": "#/$defs/tags" },
        "resource_tags": { "$ref": "#/$defs/tags" },
        "autowire": { "type": "boolean" },
        "autoconfigure": { "type": "boolean" },
        "bind": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/parameterValue" }
        }
      },
      "additionalProperties": false
    },
    "serviceInstanceof": {
      "$comment": "Applied to services declared in the current file whose class matches the key (interface or parent class).",
      "type": "object",
      "properties": {
        "shared": { "type": "boolean" },
        "lazy": { "oneOf": [ { "type": "boolean" }, { "$ref": "#/$defs/fqcn" } ] },
        "public": { "type": "boolean" },
        "properties": { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } },
        "configurator": { "$ref": "#/$defs/callable" },
        "calls": { "$ref": "#/$defs/calls" },
        "tags": { "$ref": "#/$defs/tags" },
        "resource_tags": { "$ref": "#/$defs/tags" },
        "autowire": { "type": "boolean" },
        "bind": { "type": "object", "additionalProperties": { "$ref": "#/$defs/parameterValue" } },
        "constructor": { "type": "string" }
      },
      "additionalProperties": false
    }
  }
}