Fix connection ambiguious (#13585)

* Fix ambiguious warning with validation issue

* Remove manual dependency on superset

* Fix SonarLint

* Remove extra condition

* Optimise logic

* Update parseConnectionSchema.js

* Update parseConnectionSchema.js
This commit is contained in:
Ayush Shah 2023-10-16 20:48:08 +05:30 committed by GitHub
parent cf94097e3c
commit 7f348014bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 575 deletions

View File

@ -37,6 +37,23 @@ const globalParserOptions = {
const parser = new $RefParser(globalParserOptions);
function removeObjectByKey(obj, keyToRemove) {
if (typeof (obj) == 'object') {
for (const prop in obj) {
if (prop === keyToRemove) {
// If the property key matches the key to remove, delete it
delete obj[prop];
} else {
// Recursively call the function on the property's value
obj[prop] = removeObjectByKey(obj[prop], keyToRemove);
}
}
}
return obj
}
async function parseSchema(filePath, destPath) {
try {
const fileDir = `${cwd}/${path.dirname(filePath)}`;
@ -46,6 +63,8 @@ async function parseSchema(filePath, destPath) {
const schema = await parser.dereference(parsedSchema);
const api = await parser.bundle(schema);
const dirname = `${cwd}/${path.dirname(destPath)}`;
const updatedAPIWithoutID = removeObjectByKey(api, '$id');
if (!fs.existsSync(dirname)) {
try {
fs.mkdirSync(dirname, { recursive: true });
@ -53,7 +72,7 @@ async function parseSchema(filePath, destPath) {
console.log(err);
}
}
fs.writeFileSync(`${cwd}/${destPath}`, JSON.stringify(api, null, 2));
fs.writeFileSync(`${cwd}/${destPath}`, JSON.stringify(updatedAPIWithoutID, null, 2));
} catch (err) {
console.log(err);
} finally {

View File

@ -1,573 +0,0 @@
{
"$id": "https://open-metadata.org/schema/entity/services/connections/dashboard/supersetConnection.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SupersetConnection",
"description": "Superset Connection Config",
"type": "object",
"javaType": "org.openmetadata.schema.services.connections.dashboard.SupersetConnection",
"definitions": {
"supersetType": {
"description": "Superset service type",
"type": "string",
"enum": ["Superset"],
"default": "Superset"
}
},
"properties": {
"type": {
"title": "Service Type",
"description": "Service Type",
"default": "Superset",
"type": "string",
"enum": ["Superset"]
},
"hostPort": {
"expose": true,
"title": "Host and Port",
"description": "URL for the superset instance.",
"type": "string",
"format": "uri",
"default": "http://localhost:8088"
},
"connection": {
"title": "Superset Connection",
"description": "Choose between API or database connection fetch metadata from superset.",
"oneOf": [
{
"$id": "https://open-metadata.org/schema/entity/services/connections/dashboard/supersetApiConnection.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SupersetApiConnection",
"description": "Superset API Connection Config",
"type": "object",
"definitions": {
"apiProvider": {
"title": "Provider",
"description": "Authentication provider for the Superset service. For basic user/password authentication, the default value `db` can be used. This parameter is used internally to connect to Superset's REST API.",
"type": "string",
"enum": ["db", "ldap"],
"default": "db"
}
},
"properties": {
"provider": {
"title": "Provider",
"description": "Authentication provider for the Superset service. For basic user/password authentication, the default value `db` can be used. This parameter is used internally to connect to Superset's REST API.",
"default": "db",
"type": "string",
"enum": ["db", "ldap"]
},
"username": {
"title": "Username",
"description": "Username for Superset.",
"type": "string"
},
"password": {
"title": "Password",
"description": "Password for Superset.",
"type": "string",
"format": "password"
},
"verifySSL": {
"title": "Verify SSL",
"default": "no-ssl",
"description": "Client SSL verification. Make sure to configure the SSLConfig if enabled.",
"javaType": "org.openmetadata.schema.security.ssl.VerifySSL",
"type": "string",
"enum": ["no-ssl", "ignore", "validate"]
},
"sslConfig": {
"description": "Client SSL configuration",
"javaType": "org.openmetadata.schema.security.ssl.SSLConfig",
"oneOf": [
{
"$id": "https://open-metadata.org/schema/security/ssl/validateSSLClientConfig.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Validate SSL Client Config",
"description": "OpenMetadata Client configured to validate SSL certificates.",
"type": "object",
"javaType": "org.openmetadata.schema.security.ssl.ValidateSSLClientConfig",
"properties": {
"certificatePath": {
"title": "Certificate Path",
"description": "CA certificate path. E.g., /path/to/public.cert. Will be used if Verify SSL is set to `validate`.",
"type": "string"
}
},
"additionalProperties": false
}
]
}
},
"additionalProperties": false,
"required": ["provider", "password", "username"]
},
{
"$id": "https://open-metadata.org/schema/entity/services/connections/database/postgresConnection.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "PostgresConnection",
"description": "Postgres Database Connection Config",
"type": "object",
"javaType": "org.openmetadata.schema.services.connections.database.PostgresConnection",
"definitions": {
"postgresType": {
"description": "Service type.",
"type": "string",
"enum": ["Postgres"],
"default": "Postgres"
},
"postgresScheme": {
"description": "SQLAlchemy driver scheme options.",
"type": "string",
"enum": ["postgresql+psycopg2"],
"default": "postgresql+psycopg2"
}
},
"properties": {
"type": {
"title": "Service Type",
"description": "Service Type",
"default": "Postgres",
"type": "string",
"enum": ["Postgres"]
},
"scheme": {
"title": "Connection Scheme",
"description": "SQLAlchemy driver scheme options.",
"default": "postgresql+psycopg2",
"type": "string",
"enum": ["postgresql+psycopg2"]
},
"username": {
"title": "Username",
"description": "Username to connect to Postgres. This user should have privileges to read all the metadata in Postgres.",
"type": "string"
},
"authType": {
"title": "Auth Configuration Type",
"description": "Choose Auth Config Type.",
"oneOf": [
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Basic Auth",
"description": "Common Database Connection Config",
"javaType": "org.openmetadata.schema.services.connections.database.common.basicAuth",
"type": "object",
"properties": {
"password": {
"title": "Password",
"description": "Password to connect to source.",
"type": "string",
"format": "password"
}
},
"additionalProperties": false
},
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "IAM Auth Configuration Source",
"description": "IAM Auth Database Connection Config",
"type": "object",
"javaType": "org.openmetadata.schema.services.connections.database.common.IamAuthConfig",
"properties": {
"awsConfig": {
"title": "AWS Credentials Configuration",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "AWS credentials configs.",
"type": "object",
"javaType": "org.openmetadata.schema.security.credentials.AWSCredentials",
"properties": {
"awsAccessKeyId": {
"title": "AWS Access Key ID",
"description": "AWS Access key ID.",
"type": "string"
},
"awsSecretAccessKey": {
"title": "AWS Secret Access Key",
"description": "AWS Secret Access Key.",
"type": "string",
"format": "password"
},
"awsRegion": {
"title": "AWS Region",
"description": "AWS Region",
"type": "string"
},
"awsSessionToken": {
"title": "AWS Session Token",
"description": "AWS Session Token.",
"type": "string"
},
"endPointURL": {
"title": "Endpoint URL",
"description": "EndPoint URL for the AWS",
"type": "string",
"format": "uri"
},
"profileName": {
"title": "Profile Name",
"description": "The name of a profile to use with the boto session.",
"type": "string"
},
"assumeRoleArn": {
"title": "Role Arn for Assume Role",
"description": "The Amazon Resource Name (ARN) of the role to assume. Required Field in case of Assume Role",
"type": "string"
},
"assumeRoleSessionName": {
"title": "Role Session Name for Assume Role",
"description": "An identifier for the assumed role session. Use the role session name to uniquely identify a session when the same role is assumed by different principals or for different reasons. Required Field in case of Assume Role",
"type": "string",
"default": "OpenMetadataSession"
},
"assumeRoleSourceIdentity": {
"title": "Source Identity for Assume Role",
"description": "The Amazon Resource Name (ARN) of the role to assume. Optional Field in case of Assume Role",
"type": "string"
}
},
"additionalProperties": false,
"required": ["awsRegion"]
}
},
"additionalProperties": false
}
]
},
"hostPort": {
"title": "Host and Port",
"description": "Host and port of the source service.",
"type": "string"
},
"database": {
"title": "Database",
"description": "Database of the data source. This is optional parameter, if you would like to restrict the metadata reading to a single database. When left blank, OpenMetadata Ingestion attempts to scan all the databases.",
"type": "string"
},
"sslMode": {
"title": "SSL Mode",
"description": "SSL Mode to connect to postgres database.",
"enum": [
"disable",
"allow",
"prefer",
"require",
"verify-ca",
"verify-full"
],
"default": "disable"
},
"sslConfig": {
"description": "Client SSL configuration",
"javaType": "org.openmetadata.schema.security.ssl.SSLConfig",
"oneOf": [
{
"$id": "https://open-metadata.org/schema/security/ssl/validateSSLClientConfig.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ValidateSSLClientConfig",
"description": "OpenMetadata Client configured to validate SSL certificates.",
"type": "object",
"javaType": "org.openmetadata.schema.security.ssl.ValidateSSLClientConfig",
"properties": {
"certificatePath": {
"description": "CA certificate path. E.g., /path/to/public.cert. Will be used if Verify SSL is set to `validate`.",
"type": "string"
}
},
"additionalProperties": false
}
]
},
"classificationName": {
"title": "Classification Name",
"description": "Custom OpenMetadata Classification name for Postgres policy tags.",
"type": "string",
"default": "PostgresPolicyTags"
},
"ingestAllDatabases": {
"title": "Ingest All Databases",
"description": "Ingest data from all databases in Postgres. You can use databaseFilterPattern on top of this.",
"type": "boolean",
"default": false
},
"connectionOptions": {
"title": "Connection Options",
"javaType": "org.openmetadata.schema.services.connections.database.ConnectionOptions",
"description": "Additional connection options to build the URL that can be sent to service during the connection.",
"additionalProperties": {
"type": "string"
}
},
"connectionArguments": {
"title": "Connection Arguments",
"javaType": "org.openmetadata.schema.services.connections.database.ConnectionArguments",
"description": "Additional connection arguments such as security or protocol configs that can be sent to service during connection.",
"additionalProperties": {
".{1,}": {
"type": "string"
}
}
},
"supportsMetadataExtraction": {
"title": "Supports Metadata Extraction",
"description": "Supports Metadata Extraction.",
"type": "boolean",
"default": true
},
"supportsUsageExtraction": {
"description": "Supports Usage Extraction.",
"type": "boolean",
"default": true
},
"supportsLineageExtraction": {
"description": "Supports Lineage Extraction.",
"type": "boolean",
"default": true
},
"supportsDBTExtraction": {
"description": "Supports DBT Extraction.",
"type": "boolean",
"default": true
},
"supportsProfiler": {
"title": "Supports Profiler",
"description": "Supports Profiler",
"type": "boolean",
"default": true
},
"supportsDatabase": {
"title": "Supports Database",
"description": "The source service supports the database concept in its hierarchy",
"type": "boolean",
"default": true
},
"supportsQueryComment": {
"title": "Supports Query Comment",
"description": "For Database Services using SQLAlchemy, True to enable running a comment for all queries run from OpenMetadata.",
"type": "boolean",
"default": true
}
},
"additionalProperties": false,
"required": ["hostPort", "username", "database"]
},
{
"$id": "https://open-metadata.org/schema/entity/services/connections/database/mysqlConnection.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MysqlConnection",
"description": "Mysql Database Connection Config",
"type": "object",
"javaType": "org.openmetadata.schema.services.connections.database.MysqlConnection",
"definitions": {
"mySQLType": {
"description": "Service type.",
"type": "string",
"enum": ["Mysql"],
"default": "Mysql"
},
"mySQLScheme": {
"description": "SQLAlchemy driver scheme options.",
"type": "string",
"enum": ["mysql+pymysql"],
"default": "mysql+pymysql"
}
},
"properties": {
"type": {
"title": "Service Type",
"description": "Service Type",
"default": "Mysql",
"type": "string",
"enum": ["Mysql"]
},
"scheme": {
"title": "Connection Scheme",
"description": "SQLAlchemy driver scheme options.",
"default": "mysql+pymysql",
"type": "string",
"enum": ["mysql+pymysql"]
},
"username": {
"title": "Username",
"description": "Username to connect to MySQL. This user should have privileges to read all the metadata in Mysql.",
"type": "string"
},
"authType": {
"title": "Auth Configuration Type",
"description": "Choose Auth Config Type.",
"oneOf": [
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Basic Auth",
"description": "Common Database Connection Config",
"javaType": "org.openmetadata.schema.services.connections.database.common.basicAuth",
"type": "object",
"properties": {
"password": {
"title": "Password",
"description": "Password to connect to source.",
"type": "string",
"format": "password"
}
},
"additionalProperties": false
},
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "IAM Auth Configuration Source",
"description": "IAM Auth Database Connection Config",
"type": "object",
"javaType": "org.openmetadata.schema.services.connections.database.common.IamAuthConfig",
"properties": {
"awsConfig": {
"title": "AWS Credentials Configuration",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "AWS credentials configs.",
"type": "object",
"javaType": "org.openmetadata.schema.security.credentials.AWSCredentials",
"properties": {
"awsAccessKeyId": {
"title": "AWS Access Key ID",
"description": "AWS Access key ID.",
"type": "string"
},
"awsSecretAccessKey": {
"title": "AWS Secret Access Key",
"description": "AWS Secret Access Key.",
"type": "string",
"format": "password"
},
"awsRegion": {
"title": "AWS Region",
"description": "AWS Region",
"type": "string"
},
"awsSessionToken": {
"title": "AWS Session Token",
"description": "AWS Session Token.",
"type": "string"
},
"endPointURL": {
"title": "Endpoint URL",
"description": "EndPoint URL for the AWS",
"type": "string",
"format": "uri"
},
"profileName": {
"title": "Profile Name",
"description": "The name of a profile to use with the boto session.",
"type": "string"
},
"assumeRoleArn": {
"title": "Role Arn for Assume Role",
"description": "The Amazon Resource Name (ARN) of the role to assume. Required Field in case of Assume Role",
"type": "string"
},
"assumeRoleSessionName": {
"title": "Role Session Name for Assume Role",
"description": "An identifier for the assumed role session. Use the role session name to uniquely identify a session when the same role is assumed by different principals or for different reasons. Required Field in case of Assume Role",
"type": "string",
"default": "OpenMetadataSession"
},
"assumeRoleSourceIdentity": {
"title": "Source Identity for Assume Role",
"description": "The Amazon Resource Name (ARN) of the role to assume. Optional Field in case of Assume Role",
"type": "string"
}
},
"additionalProperties": false,
"required": ["awsRegion"]
}
},
"additionalProperties": false
}
]
},
"hostPort": {
"title": "Host and Port",
"description": "Host and port of the MySQL service.",
"type": "string"
},
"databaseName": {
"title": "Database Name",
"description": "Optional name to give to the database in OpenMetadata. If left blank, we will use default as the database name.",
"type": "string"
},
"databaseSchema": {
"title": "Database Schema",
"description": "Database Schema of the data source. This is optional parameter, if you would like to restrict the metadata reading to a single schema. When left blank, OpenMetadata Ingestion attempts to scan all the schemas.",
"type": "string"
},
"sslCA": {
"title": "SSL CA",
"description": "Provide the path to ssl ca file",
"type": "string"
},
"sslCert": {
"title": "SSL Client Certificate File",
"description": "Provide the path to ssl client certificate file (ssl_cert)",
"type": "string"
},
"sslKey": {
"title": "SSL Client Key File",
"description": "Provide the path to ssl client certificate file (ssl_key)",
"type": "string"
},
"connectionOptions": {
"title": "Connection Options",
"javaType": "org.openmetadata.schema.services.connections.database.ConnectionOptions",
"description": "Additional connection options to build the URL that can be sent to service during the connection.",
"additionalProperties": {
"type": "string"
}
},
"connectionArguments": {
"title": "Connection Arguments",
"javaType": "org.openmetadata.schema.services.connections.database.ConnectionArguments",
"description": "Additional connection arguments such as security or protocol configs that can be sent to service during connection.",
"additionalProperties": {
".{1,}": {
"type": "string"
}
}
},
"supportsMetadataExtraction": {
"title": "Supports Metadata Extraction",
"description": "Supports Metadata Extraction.",
"type": "boolean",
"default": true
},
"supportsDBTExtraction": {
"description": "Supports DBT Extraction.",
"type": "boolean",
"default": true
},
"supportsProfiler": {
"title": "Supports Profiler",
"description": "Supports Profiler",
"type": "boolean",
"default": true
},
"supportsQueryComment": {
"title": "Supports Query Comment",
"description": "For Database Services using SQLAlchemy, True to enable running a comment for all queries run from OpenMetadata.",
"type": "boolean",
"default": true
}
},
"additionalProperties": false,
"required": ["hostPort", "username"]
}
]
},
"supportsMetadataExtraction": {
"title": "Supports Metadata Extraction",
"description": "Supports Metadata Extraction.",
"type": "boolean",
"default": true
}
},
"additionalProperties": false,
"required": ["hostPort", "connection"]
}

View File

@ -27,8 +27,8 @@ import powerBIConnection from '../jsons/connectionSchemas/connections/dashboard/
import qliksenseConnection from '../jsons/connectionSchemas/connections/dashboard/qlikSenseConnection.json';
import quicksightConnection from '../jsons/connectionSchemas/connections/dashboard/quickSightConnection.json';
import redashConnection from '../jsons/connectionSchemas/connections/dashboard/redashConnection.json';
import supersetConnection from '../jsons/connectionSchemas/connections/dashboard/supersetConnection.json';
import tableauConnection from '../jsons/connectionSchemas/connections/dashboard/tableauConnection.json';
import supersetConnection from './ConnectionSchemas/SupersetConnection.json';
export const getDashboardURL = (config: DashboardConnection['config']) => {
return !isUndefined(config) && !isEmpty(config.hostPort)