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 bal openapi sanitize sub command #1770

Merged
merged 18 commits into from
Sep 19, 2024
Merged

Conversation

TharmiganK
Copy link
Contributor

@TharmiganK TharmiganK commented Sep 11, 2024

Purpose

$Subject

Part of: ballerina-platform/ballerina-library#6977

This modifies all the schema names with Ballerina friendly names. The following schemas can not be modified directly:

  • Query and Header Parameters
  • Properties of Object schemas

In that case a Ballerina extension: x-ballerina-name is added to the schemas, which will be used to generate annotations in the client/service generation. Refer to this proposal for more details.

Description

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 naming
       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
       directly.


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

@TharmiganK TharmiganK changed the title Sanitize sub command Introduce bal openapi sanitize sub command Sep 11, 2024
@TharmiganK TharmiganK marked this pull request as ready for review September 11, 2024 09:16
# Conflicts:
#	openapi-cli/src/main/java/io/ballerina/openapi/cmd/CmdConstants.java
#	openapi-cli/src/main/java/io/ballerina/openapi/cmd/OpenApiCmd.java
#	openapi-cli/src/test/java/io/ballerina/openapi/cmd/NegativeCmdTests.java
#	openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java
Copy link

sonarcloud bot commented Sep 19, 2024

@TharmiganK TharmiganK merged commit ca9bb7e into master Sep 19, 2024
4 checks passed
@TharmiganK TharmiganK deleted the sanitize-sub-command branch September 19, 2024 08:05
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.

3 participants