Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2201.8.7-stage] Include configurable variables in imported packages to the schema #42919

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

Dilhasha
Copy link
Contributor

Purpose

Add support to configure configurable variables in imported packages to the schema

Fixes https://github.com/wso2-enterprise/internal-support-ballerina/issues/690

Approach

Extend existing implementation to get the configurable variables for the imports as well.

Samples

  • Create a ballerina package
  • Update the content in default module with the following.

main.bal

import ballerina/log;

configurable string itemCode = "item12393";

public function main() {
    log:printInfo("hello");
    log:printInfo("hello debug");
}

The generated config-schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "ballerina": {
      "type": "object",
      "properties": {
        "log": {
          "type": "object",
          "properties": {
            "format": {
              "type": "string",
              "description": ""
            },
            "level": {
              "type": "string",
              "description": ""
            },
            "modules": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "level": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "name",
                  "level"
                ],
                "name": "ballerina/log:2.9.0:Module"
              },
              "description": ""
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "dilhashanazeer": {
      "type": "object",
      "properties": {
        "simpleconfigs": {
          "type": "object",
          "properties": {
            "itemCode": {
              "type": "string",
              "description": ""
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}

Remarks

TODO:
Add test cases in the distribution repository - ballerina-platform/ballerina-distribution#5445

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@Dilhasha Dilhasha merged commit 963d065 into ballerina-platform:2201.8.7-stage Jun 13, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants