Skip to content

[Schema Inefficiency] Lots of code duplication in components that have a nullable-* counterpart #544

Open
@gr2m

Description

@gr2m

follow up to #543 (review)

Is there any way to remove the duplication between the existing components and their newly introduced nullable-* counterparts?

Example:

      "nullable-license-simple": {
        "title": "License Simple",
        "description": "License Simple",
        "type": "object",
        "properties": {
          "key": { "type": "string", "example": "mit" },
          "name": { "type": "string", "example": "MIT License" },
          "url": {
            "type": "string",
            "nullable": true,
            "format": "uri",
            "example": "https://api.github.com/licenses/mit"
          },
          "spdx_id": { "type": "string", "nullable": true, "example": "MIT" },
          "node_id": { "type": "string", "example": "MDc6TGljZW5zZW1pdA==" },
          "html_url": { "type": "string", "format": "uri" }
        },
        "required": ["key", "name", "url", "spdx_id", "node_id"],
        "nullable": true
      },

and

      "license-simple": {
        "title": "License Simple",
        "description": "License Simple",
        "type": "object",
        "properties": {
          "key": { "type": "string", "example": "mit" },
          "name": { "type": "string", "example": "MIT License" },
          "url": {
            "type": "string",
            "nullable": true,
            "format": "uri",
            "example": "https://api.github.com/licenses/mit"
          },
          "spdx_id": { "type": "string", "nullable": true, "example": "MIT" },
          "node_id": { "type": "string", "example": "MDc6TGljZW5zZW1pdA==" },
          "html_url": { "type": "string", "format": "uri" }
        },
        "required": ["key", "name", "url", "spdx_id", "node_id"]
      },

Is nearly the same, the only diff is

+ "nullable": true

This will generate a ton of unnecessary code down the line.

It's not a critical problem, but I'd appreciate if we could remove the duplication somehow

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions