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

Add jsondata:Name and http:Header mapping for record fields in the OpenAPI generation #1773

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

TharmiganK
Copy link
Contributor

@TharmiganK TharmiganK commented Sep 20, 2024

Purpose

$Subject

Fixes: ballerina-platform/ballerina-library#7014

This PR also address the mapping for header annotation with a record type:

TODO: Add tests for header once it is supported in HTTP

import ballerina/data.jsondata;
import ballerina/http;

public type Album record {|
    string artist;
    @jsondata:Name {value: "_id"}
    string id;
    string title;
|};

public type Headers record {|
    @http:Header {name: "X-API-VERSION"}
    string? xAPIVERSION = "v1";
|};

@http:ServiceConfig {basePath: "/api/v1"}
type OASServiceType service object {
    *http:ServiceContract;
    resource function get albums(@http:Header Headers xAPIVERSION) returns Album[];
};
...
  /albums:
    get:
      operationId: getAlbums
      parameters:
      - name: X-API-VERSION
        in: header
        schema:
          type: string
          nullable: true
          default: v1
...

@TharmiganK TharmiganK changed the title Add jsondata name attribute mapping in the OpenAPI generation Add jsondata:Name and http:Header mapping for record fields in the OpenAPI generation Sep 20, 2024
Copy link

sonarcloud bot commented Sep 20, 2024

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.

Add jsondata name attribute mapping in the OpenAPI generation
2 participants