Skip to content

Conversation

@adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Jul 3, 2023

Question Answer
JIRA Ticket
Versions 4.5
Edition

RAML syntax

  • In RAML, it's mandatory to type array items. There is two ways to do so:
    • the PHPDoc way:
      type: <type>[]
    • the RAML way:
      type: array
      items: <type>
  • In RAML, like in YAML, a key can't have no value.

Disrespect of those rules generates errors when using a more recent RAML parser (see #1871).

Array items typing

I set items: mixed when I wasn't able to identify the expected types for the property items.

There is no associative arrays in JSON, only objects. Several arrays were in fact objects.

For names and descriptions properties, there are two ways:

  • type: Value[] for the old way; ObjectStateGroup examples:
      <names>
          <value languageCode="eng-GB">Custom State</value>
      </names>
          "names": {
              "value": [
                  {
                      "_languageCode": "eng-GB",
                      "#text": "Custom State"
                  }
              ]
          },
  • type: object for the new way; PaymentMethodUpdateStruct example
      <names>
          <eng-GB>Bank transfer (updated)</eng-GB>
      </names>
      "names": {
        "eng-GB": "Bank transfer (updated)"
      }
    Notice that this is not an array. PHP associative arrays are objects in JSON.
    I do not know how to describe the property of this object as their keys are dynamics, they depends on client's needed languages.
    What is the way to write this in XML?

Some types aren't used an may not need further investigation. "Unused" means that there is no REST route declaring type: <type> in its body or responses ("direct usage"), and there is no used other type using it for its properties ("indirect usage").

Updated types

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@MagdalenaZuba MagdalenaZuba marked this pull request as ready for review July 4, 2023 08:38
`AttributeGroupCreate` got no `languages` property.

- No `languages` is parsed in https://github.com/ibexa/product-catalog/blob/main/src/bundle/REST/Input/Parser/AttributeGroupCreate.php
- No `languages` in examples/product/catalog/attribute_groups/POST/AttributeGroupCreate.json.example
Language is only used in response to GET /languages/{code} or GET /languages (see docs/api/rest_api/rest_api_reference/input/ez-languages.raml)

The Language::ALL constant can't be used in REST

It comes from https://github.com/ibexa/core/blob/main/src/contracts/Repository/Values/Content/Language.php#L26

Language has no REST input parser.

Language's output parser never use ALL (see https://github.com/ibexa/rest/blob/main/src/lib/Server/Output/ValueObjectVisitor/Language.php)
@adriendupuis adriendupuis marked this pull request as draft July 5, 2023 12:47
adriendupuis added a commit that referenced this pull request Jul 7, 2023
@adriendupuis adriendupuis merged commit 6813729 into master Jul 7, 2023
@adriendupuis adriendupuis deleted the fix-raml-syntax branch July 7, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants