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

OpenAPI generated does not have all types #6980

Open
shirolk opened this issue Sep 10, 2024 · 2 comments
Open

OpenAPI generated does not have all types #6980

shirolk opened this issue Sep 10, 2024 · 2 comments

Comments

@shirolk
Copy link

shirolk commented Sep 10, 2024

Description:
In the types definition that is used for a Ballerina service there is a type which is a union of constants. This type is part of a struct.

public const RESOURCE_KIND_ENVIRONMENT = "Environment";
public const RESOURCE_KIND_PROJECT = "Project";
public const RESOURCE_KIND_COMPONENT = "Component";
public const RESOURCE_KIND_BUILD = "Build";
public const RESOURCE_KIND_DEPLOYABLE_ARTIFACT = "DeployableArtifact";
public const RESOURCE_KIND_DEPLOYMENT = "Deployment";

public type ResourceKind RESOURCE_KIND_ENVIRONMENT|RESOURCE_KIND_PROJECT|RESOURCE_KIND_COMPONENT|RESOURCE_KIND_BUILD|
    RESOURCE_KIND_DEPLOYABLE_ARTIFACT|RESOURCE_KIND_DEPLOYMENT;

public type Environment record {
    string apiVersion;
    RESOURCE_KIND_ENVIRONMENT kind = RESOURCE_KIND_ENVIRONMENT;
    Metadata metadata;
    EnvironmentSpec spec;
    EnvironmentStatus status?;
};

When the OpenAPI tool is used to generate the OpenAPI Spec this type is omitted.
bal openapi -i service.bal

Later this spec is used to generate a client and as a result the resulting types have a missing field
bal openapi -i <spec_location> -o <generate_location> --mode client

public type Environment record {
    string apiVersion;
    Metadata metadata;
    EnvironmentSpec spec;
    EnvironmentStatus status?;
};

Suggested Labels (optional):
module/openapi-tools
Area/OpenapiToBallerina
Area/BallerinaToOpenapi

@lnash94
Copy link
Member

lnash94 commented Sep 10, 2024

Currently, the tool won't support the literal value, the tool will support the defined types. In the above scenarios is there a particular reason to add a kind as a literal value, if possible to have a kind with ResourceKind we will map the kind type to the given type.

public type Environment record {
    string apiVersion;
    ResourceKind kind = RESOURCE_KIND_ENVIRONMENT;
    Metadata metadata;
    EnvironmentSpec spec;
    EnvironmentStatus status?;
};

@TharmiganK
Copy link
Contributor

There are two issues here:

  1. The constant value expression is not yet supported for the default value mapping. Only the following expression types are supported: https://github.com/ballerina-platform/openapi-tools/blob/c2785574f50aed737bfd99d23d810a0a6cf37956/ballerina-to-openapi/src/main/java/io/ballerina/openapi/service/mapper/utils/MapperCommonUtils.java#L115
  2. The singleton type is not yet supported in the OpenAPI mapping. The currently supported basic types given in the spec: https://github.com/ballerina-platform/openapi-tools/blob/master/docs/ballerina-to-oas/spec/spec.md#the-ballerina-type-to-schema-mapping

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

No branches or pull requests

3 participants