Skip to content

Support of null for other referenced types #261

@Antreesy

Description

@Antreesy

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Based on https://github.com/nextcloud/spreed/blob/e6d2969c3ce08f70d52375e703a7b4e9986e6110/lib/ResponseDefinitions.php:

Primitives converted correctly:

 * @psalm-type TalkBot = array{
 *     description: ?string,
 * }
"required": [
    "description",
],
"properties": {
    "description": {
        "type": "string",
        "nullable": true
    },
Bot: {
    description: string | null;
}

But the same doesn't happen to other psalm-types:

 * @psalm-type TalkThreadInfo = array{
 *      first: ?TalkChatMessage,
 * }
"required": [
    "first",
],
"properties": {
  "first": {
      "$ref": "#/components/schemas/ChatMessage",
      "nullable": true
  },

Actual behaviour

ThreadInfo: {
   first: components["schemas"]["ChatMessage"];
}

Expected behaviour

ThreadInfo: {
   first: components["schemas"]["ChatMessage"] | null;
}

As i found out, they changed handling of nullables in 3.1.0, so after some playing around: this JSON output would work as expected:

"first": {
  "oneOf": [
    { "$ref": "#/components/schemas/ChatMessage" },
    { "type": "null" }
  ]
},
Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

☑️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions