-
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.
Enable resource config annotation for service contract type
- Loading branch information
Showing
3 changed files
with
148 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
83 changes: 83 additions & 0 deletions
83
.../resources/ballerina_sources/project_resource_info_with_service_contract_type/result.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,83 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: V1 | ||
version: 2.0.0 | ||
servers: | ||
- url: "http://{server}:{port}/v1" | ||
variables: | ||
server: | ||
default: localhost | ||
port: | ||
default: "8080" | ||
paths: | ||
/user: | ||
post: | ||
tags: | ||
- user | ||
operationId: postUser | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/User' | ||
examples: | ||
user01: | ||
value: | ||
id: "123" | ||
name: Jessica | ||
required: true | ||
responses: | ||
"201": | ||
description: Created | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/User' | ||
examples: | ||
Jessica: | ||
value: | ||
id: "123" | ||
name: Jessica | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorPayload' | ||
components: | ||
schemas: | ||
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 | ||
User: | ||
required: | ||
- id | ||
- name | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
additionalProperties: false |
58 changes: 58 additions & 0 deletions
58
...urces/ballerina_sources/project_resource_info_with_service_contract_type/service_file.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,58 @@ | ||
// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/http; | ||
import ballerina/openapi; | ||
|
||
@http:ServiceConfig {basePath: "/v1"} | ||
type OASServiceType service object { | ||
*http:ServiceContract; | ||
@openapi:ResourceInfo { | ||
tags: ["user"], | ||
examples: { | ||
response: { | ||
"201": { | ||
"examples": { | ||
"application/json": { | ||
"Jessica": { | ||
"value": { | ||
"id" : "123", | ||
"name": "Jessica" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
requestBody: { | ||
"application/json": { | ||
"user01": { | ||
"value": { | ||
"id": "123", | ||
"name": "Jessica" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
resource function post user(User user) returns User; | ||
}; | ||
|
||
public type User record {| | ||
int id; | ||
string name; | ||
|}; |