Documentation: Clarify method annotation's schema annotation format

Created on 14 March 2022, over 2 years ago
Updated 14 September 2024, 2 months ago

Problem/Motivation

I chased my tail for a good 2 hours today trying to figure out why I had parsing errors in my method's schema annotation. After a deeper dive than I'd ever like to do into Doctrine Annotations' internals, it turns out that you can use either a : or an = as a separator for key/value pairs.

I have a schema like:

 *    "store" = @JsonRpcParameterDefinition(
 *       schema = {"type" = "string", "enum" = {"google", "apple"}},
 *       required = true,
 *     ),

which includes an enum; I had been writing this as straight JSON-schema because the examples throughout the core module look like

 *     "permission" = @JsonRpcParameterDefinition(schema = {"type": "string"}),

(notice the colon instead of equal sign) which had my brain in JSON-mode. Turns out that Doctrine chokes on square brackets ([ and ]).

Steps to reproduce

Set the schema annotation parameter to a JSON-schema string that includes square brackets and break your annotation.

Proposed resolution

Better documentation.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

Live updates comments and jobs are added and updated live.
  • DrupalWTF

    Worse Than Failure. Approximates the unpleasant remark made by Drupal developers when they first encounter a particular (mis)feature.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024