@@ -118,6 +118,53 @@ App\Entity\Book:
118
118
groups: ['write']
119
119
` ` `
120
120
121
+ ` ` ` xml
122
+ <!-- api/config/api_platform/resources.xml -->
123
+ <?xml version="1.0" encoding="UTF-8" ?>
124
+ <resources xmlns="https://api-platform.com/schema/metadata/resources-3.0"
125
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
126
+ xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
127
+ https://api-platform.com/schema/metadata/resources-3.0.xsd">
128
+ <resource class="App\E ntity\B ook">
129
+ <normalizationContext>
130
+ <values>
131
+ <value name="groups">
132
+ <values>
133
+ <value>read</value>
134
+ </values>
135
+ </value>
136
+ </values>
137
+ </normalizationContext>
138
+ <denormalizationContext>
139
+ <values>
140
+ <value name="groups">
141
+ <values>
142
+ <value>write</value>
143
+ </values>
144
+ </value>
145
+ </values>
146
+ </denormalizationContext>
147
+ </resource>
148
+ </resources>
149
+
150
+ <!-- api/config/serialization/Book.xml -->
151
+ <?xml version="1.0" encoding="UTF-8" ?>
152
+ <serializer xmlns="http://symfony.com/schema/dic/serializer-mapping"
153
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
154
+ xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping
155
+ http://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd">
156
+ <class name="App\E ntity\B ook">
157
+ <attribute name="name">
158
+ <group>read</group>
159
+ <group>write</group>
160
+ </attribute>
161
+ <attribute name="author">
162
+ <group>write</group>
163
+ </attribute>
164
+ </class>
165
+ </serializer>
166
+ ` ` `
167
+
121
168
[/codeSelector]
122
169
123
170
In the previous example, the `name` property will be visible when reading (`GET`) the object, and it will also be available
@@ -191,6 +238,58 @@ App\Entity\Book:
191
238
groups: ['get']
192
239
` ` `
193
240
241
+ ` ` ` xml
242
+ <!-- api/config/api_platform/resources.xml -->
243
+ <?xml version="1.0" encoding="UTF-8" ?>
244
+ <resources xmlns="https://api-platform.com/schema/metadata/resources-3.0"
245
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
246
+ xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
247
+ https://api-platform.com/schema/metadata/resources-3.0.xsd">
248
+ <resource class="App\E ntity\B ook">
249
+ <normalizationContext>
250
+ <values>
251
+ <value name="groups">
252
+ <values>
253
+ <value>get</value>
254
+ </values>
255
+ </value>
256
+ </values>
257
+ </normalizationContext>
258
+ <operations>
259
+ <operation class="ApiPlatform\M etadata\G et" />
260
+ <operation class="ApiPlatform\M etadata\P ut">
261
+ <normalizationContext>
262
+ <values>
263
+ <value name="groups">
264
+ <values>
265
+ <value>put</value>
266
+ </values>
267
+ </value>
268
+ </values>
269
+ </normalizationContext>
270
+ </operation>
271
+ </operations>
272
+ </resource>
273
+ </resources>
274
+
275
+ <!-- api/config/serialization/Book.xml -->
276
+ <?xml version="1.0" encoding="UTF-8" ?>
277
+ <serializer xmlns="http://symfony.com/schema/dic/serializer-mapping"
278
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
279
+ xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping
280
+ http://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd">
281
+ <class name="App\E ntity\B ook">
282
+ <attribute name="name">
283
+ <group>get</group>
284
+ <group>put</group>
285
+ </attribute>
286
+ <attribute name="author">
287
+ <group>get</group>
288
+ </attribute>
289
+ </class>
290
+ </serializer>
291
+ ` ` `
292
+
194
293
[/codeSelector]
195
294
196
295
The `name` and `author` properties will be included in the document generated during a `GET` operation because the configuration
0 commit comments