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

Introduce OpenAPI sanitize and flatten sub commands #6977

Closed
2 tasks done
TharmiganK opened this issue Sep 9, 2024 · 2 comments
Closed
2 tasks done

Introduce OpenAPI sanitize and flatten sub commands #6977

TharmiganK opened this issue Sep 9, 2024 · 2 comments

Comments

@TharmiganK
Copy link
Contributor

TharmiganK commented Sep 9, 2024

Description:

$Subject

Describe your task(s)

  • Introduce bal openapi sanitize sub command
  • Introduce bal openapi flatten sub command

Related Issues (optional):

Part of [Proposal] Convert the OAS to Ballerina-friendly naming conventions

@TharmiganK
Copy link
Contributor Author

TharmiganK commented Sep 9, 2024

The following is the outline of the bal openapi flatten subcommand:

NAME
       bal openapi flatten - Flatten the OpenAPI contract file

SYNOPSIS
       bal openapi flatten [-i | --input] <openapi-contract-file-path>
                           [-o | --output] <output-file-path>
                           [-n | --name] <generated-file-name>
                           [-f | --format] [json|yaml]
                           [-t | --tags] <tag-names>
                           [--operations] <operation-names>

DESCRIPTION
       Flatten the OpenAPI contract file by moving all the inline schemas to the
       components section. The generated schema names will be Ballerina friendly.

OPTIONS
       -i, --input <openapi-contract-file-path>
            This is a mandatory input. The given OpenAPI contract will be flatten.
            The OpenAPI contract can be either a YAML or a JSON.

       -o, --output <output-file-path>
            This is an optional input. The given output file path will be used to
            save the flatten OpenAPI contract. The default output file path is the
            executed directory.

       -n, --name <generated-file-name>
            This is an optional input. The given name will be used to save the
            flatten OpenAPI contract. The default name is `flattened_openapi`.

       -f, --format [json|yaml]
            This is an optional input. The flatten OpenAPI contract will be saved
            in given format. The format can be either JSON or YAML.
            The default format is same as the input format.

       -t, --tags <tag-names>
            This is an optional input. The flatten OpenAPI contract will only have
            the operations with the given tags.

       --operations <operation-names>
            This is an optional input. The flatten OpenAPI contract will only have
            the given operations.

EXAMPLES
       Flatten the `service.yaml` OpenAPI contract file.
           $ bal openapi flatten -i service.yaml

       Flatten the `service.yaml` OpenAPI contract file and save it as
       `flatten_service.json` file.
           $ bal openapi flatten -i hello.yaml -n flatten_service -f json

       Flatten the `service.json` OpenAPI contract file by filtering the
       operations with the `service` tag.
           $ bal openapi flatten -i service.json -t service

@lnash94 @daneshk @shafreenAnfar Appreciate your inputs on these options

@TharmiganK
Copy link
Contributor Author

The following is the outline of the bal openapi sanitize subcommand:

NAME
       bal openapi sanitize - Sanitize the OpenAPI contract file according to 
       the best practices of Ballerina.

SYNOPSIS
       bal openapi sanitize [-i | --input] <openapi-contract-file-path>
                            [-o | --output] <output-file-path>
                            [-n | --name] <generated-file-name>
                            [-f | --format] [json|yaml]
                            [-t | --tags] <tag-names>
                            [--operations] <operation-names>

DESCRIPTION
       Sanitize the OpenAPI contract file according to the best practices of 
       Ballerina. The OpenAPI contract is flatten and the type schema names
       are made Ballerina friendly. The Ballerina name extensions are added 
       to the schemas which can not be modified.


OPTIONS
       -i, --input <openapi-contract-file-path>
            This is a mandatory input. The given OpenAPI contract will be sanitized.
            The OpenAPI contract can be either a YAML or a JSON.

       -o, --output <output-file-path>
            This is an optional input. The given output file path will be used to
            save the sanitized OpenAPI contract. The default output file path is 
            the executed directory.

       -n, --name <generated-file-name>
            This is an optional input. The given name will be used to save the
            sanitized OpenAPI contract. The default name is `sanitized_openapi`.

       -f, --format [json|yaml]
            This is an optional input. The sanitized OpenAPI contract will be 
            saved in the given format. The format can be either JSON or YAML.
            The default format is same as the input file format.

       -t, --tags <tag-names>
            This is an optional input. The sanitized OpenAPI contract will only
            have the operations with the given tags.

       --operations <operation-names>
            This is an optional input. The sanitized OpenAPI contract will only
            have the given operations.

EXAMPLES
       Sanitize the `service.yaml` OpenAPI contract file.
           $ bal openapi sanitize -i service.yaml

       Sanitize the `service.yaml` OpenAPI contract file and save it as
       `sanitized_svc.json` file.
           $ bal openapi sanitize -i hello.yaml -n sanitized_svc -f json

       Sanitize the `service.json` OpenAPI contract file by filtering the
       operations with the `service` tag.
           $ bal openapi sanitize -i service.json -t service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants