Skip to content

API().get_schema_type_mapping(args) is missing information about a possible index signature in a schema #187

Open
@diefans

Description

@diefans

Bug Report

I want to programmatically inspect and deal with KCL schema information und stumbled upon the inability to know anything about the index signature of a schema.

1. Minimal reproduce step (Required)

create a file: test.k

schema Foo:

schema IndexSchema:
    [foo: str]: Foo

schema Test:
    attr: str
    index: IndexSchema
from google.protobuf.json_format import MessageToJson
from kcl_lib import api

exec_args = api.ExecProgram_Args(k_filename_list=["test.k"])
args = api.GetSchemaTypeMapping_Args(exec_args=exec_args)
result = api.API().get_schema_type_mapping(args)

print(MessageToJson(result))

2. What did you expect to see? (Required)

Some field indicating the name and type of the index signature [<index_attr_name>: <index_attr_type>]: <index_type> and also if it is open to contain yet unknown attributes using [...<index_attr_type>]: <index_type> where index_attr_name == "...".

3. What did you see instead (Required)

{
  "schemaTypeMapping": {
    "Foo": {
      "type": "schema",
      "schemaName": "Foo",
      "filename": "./test.k",
      "pkgPath": "__main__"
    },
    "IndexSchema": {
      "type": "schema",
      "schemaName": "IndexSchema",
      "properties": {
        "bar": {
          "type": "schema",
          "schemaName": "Foo",
          "line": 1,
          "filename": "./test.k",
          "pkgPath": "__main__"
        }
      },
      "required": [
        "bar"
      ],
      "filename": "./test.k",
      "pkgPath": "__main__"
    },
    "Test": {
      "type": "schema",
      "schemaName": "Test",
      "properties": {
        "index": {
          "type": "schema",
          "schemaName": "IndexSchema",
          "properties": {
            "bar": {
              "type": "schema",
              "schemaName": "Foo",
              "line": 1,
              "filename": "./test.k",
              "pkgPath": "__main__"
            }
          },
          "required": [
            "bar"
          ],
          "line": 2,
          "filename": "./test.k",
          "pkgPath": "__main__"
        },
        "attr": {
          "type": "str",
          "line": 1
        }
      },
      "required": [
        "attr",
        "index"
      ],
      "filename": "./test.k",
      "pkgPath": "__main__"
    }
  }
}

4. What is your KCL components version? (Required)

0.11.0-linux-amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions