-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
960593e
commit 57b2c6d
Showing
3 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...resources/ballerina-to-openapi/expected_gen/record/record_field_with_name_annotation.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: PayloadV | ||
version: 0.0.0 | ||
servers: | ||
- url: "http://{server}:{port}/payloadV" | ||
variables: | ||
server: | ||
default: localhost | ||
port: | ||
default: "8080" | ||
paths: | ||
/albums: | ||
get: | ||
operationId: getAlbums | ||
parameters: | ||
- name: artists | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
default: [] | ||
- name: X-API-VERSION | ||
in: header | ||
schema: | ||
type: string | ||
nullable: true | ||
default: v1 | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Album" | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ErrorPayload" | ||
post: | ||
operationId: postAlbums | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Album" | ||
required: true | ||
responses: | ||
"201": | ||
description: Created | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Album" | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ErrorPayload" | ||
/albums/{id}: | ||
get: | ||
operationId: getAlbumsId | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Album" | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ErrorPayload" | ||
components: | ||
schemas: | ||
Album: | ||
required: | ||
- _id | ||
- _title | ||
- artist | ||
type: object | ||
properties: | ||
artist: | ||
type: string | ||
_id: | ||
type: string | ||
_title: | ||
type: string | ||
additionalProperties: false | ||
ErrorPayload: | ||
required: | ||
- message | ||
- method | ||
- path | ||
- reason | ||
- status | ||
- timestamp | ||
type: object | ||
properties: | ||
timestamp: | ||
type: string | ||
status: | ||
type: integer | ||
format: int64 | ||
reason: | ||
type: string | ||
message: | ||
type: string | ||
path: | ||
type: string | ||
method: | ||
type: string |
20 changes: 20 additions & 0 deletions
20
...-cli/src/test/resources/ballerina-to-openapi/record/record_field_with_name_annotation.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ballerina/data.jsondata; | ||
import ballerina/http; | ||
|
||
@http:ServiceConfig {basePath: "/payloadV"} | ||
type OASServiceType service object { | ||
*http:ServiceContract; | ||
resource function get albums(string[] artists = [], @http:Header {name: "X-API-VERSION"} string? xAPIVERSION = "v1") returns Album[]; | ||
resource function post albums(Album payload) returns Album; | ||
resource function get albums/[string id]() returns Album; | ||
}; | ||
|
||
const titleField = "_title"; | ||
|
||
public type Album record {| | ||
string artist; | ||
@jsondata:Name {value: "_id"} | ||
string id; | ||
@jsondata:Name {value: titleField} | ||
string title; | ||
|}; |