Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions airbyte_cdk/cli/airbyte_cdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from airbyte_cdk.cli.airbyte_cdk._connector import connector_cli_group
from airbyte_cdk.cli.airbyte_cdk._image import image_cli_group
from airbyte_cdk.cli.airbyte_cdk._manifest import manifest_cli_group
from airbyte_cdk.cli.airbyte_cdk._metadata import metadata_cli_group
from airbyte_cdk.cli.airbyte_cdk._secrets import secrets_cli_group
from airbyte_cdk.cli.airbyte_cdk._version import print_version

Expand Down Expand Up @@ -78,6 +79,7 @@ def cli(

cli.add_command(connector_cli_group)
cli.add_command(manifest_cli_group)
cli.add_command(metadata_cli_group)
cli.add_command(image_cli_group)
cli.add_command(secrets_cli_group)

Expand Down
75 changes: 75 additions & 0 deletions airbyte_cdk/cli/airbyte_cdk/_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
"""CLI commands for metadata validation."""

import json
import sys
from pathlib import Path

import rich_click as click

from airbyte_cdk.models.connector_metadata import validate_metadata_file


@click.group(name="metadata")
def metadata_cli_group() -> None:
"""Commands for working with connector metadata."""
pass


@metadata_cli_group.command(name="validate")
@click.option(
"--file",
"-f",
"file_path",
type=click.Path(exists=True, path_type=Path),
required=True,
help="Path to the metadata.yaml file to validate",
)
@click.option(
"--schema",
"-s",
"schema_source",
type=str,
default=None,
help="URL or file path to JSON schema (defaults to monorepo schema)",
)
@click.option(
"--format",
"output_format",
type=click.Choice(["json", "text"]),
default="text",
help="Output format (json or text)",
)
def validate_command(file_path: Path, schema_source: str | None, output_format: str) -> None:
"""Validate a connector metadata.yaml file.

This command validates a metadata.yaml file against the connector metadata schema
and reports any validation errors.

Examples:
airbyte-cdk metadata validate --file metadata.yaml
airbyte-cdk metadata validate --file metadata.yaml --format json
airbyte-cdk metadata validate --file metadata.yaml --schema /path/to/schema.json
"""
result = validate_metadata_file(file_path, schema_source)

if output_format == "json":
click.echo(result.model_dump_json(indent=2))
else:
if result.valid:
click.secho("✓ Metadata file is valid", fg="green")
else:
click.secho("✗ Metadata file is invalid", fg="red")
click.echo()
click.echo("Errors:")
for error in result.errors:
error_type = error.get("type", "unknown")
path = error.get("path", "")
message = error.get("message", "")

if path:
click.echo(f" • {path}: {message} (type: {error_type})")
else:
click.echo(f" • {message} (type: {error_type})")

sys.exit(0 if result.valid else 1)
111 changes: 0 additions & 111 deletions airbyte_cdk/models/connector_metadata.py

This file was deleted.

23 changes: 23 additions & 0 deletions airbyte_cdk/models/connector_metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Connector metadata models and validation."""

from airbyte_cdk.models.connector_metadata.metadata_file import (
ConnectorBuildOptions,
ConnectorLanguage,
ConnectorMetadata,
MetadataFile,
SuggestedStreams,
ValidationResult,
get_metadata_schema,
validate_metadata_file,
)

__all__ = [
"ConnectorBuildOptions",
"ConnectorLanguage",
"ConnectorMetadata",
"MetadataFile",
"SuggestedStreams",
"ValidationResult",
"get_metadata_schema",
"validate_metadata_file",
]
Loading
Loading