Skip to content

Commit

Permalink
Add tests for request body mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK committed Jan 24, 2024
1 parent 809b57a commit 3b5226b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorPayload'
/student3:
post:
operationId: postStudent3
parameters:
- name: q
in: query
required: true
schema:
type: string
requestBody:
content:
text/plain:
schema:
type: string
responses:
"201":
description: Created
content:
application/json:
schema:
type: object
"400":
description: BadRequest
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorPayload'
components:
schemas:
ErrorPayload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ service /payloadV on ep0 {
resource function post student2(@http:Payload string p, string q) returns json {
return {Name: p};
}

resource function post student3(@http:Payload string? p, string q) returns json {
return {Name: p ?: q};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ service /payloadV on new http:Listener(port) {
}
}

resource function post albums(@http:Payload Album album) returns Album {
resource function post albums(@http:Payload readonly & Album album) returns Album {
albums.add(album);
return album;
}
Expand Down

0 comments on commit 3b5226b

Please sign in to comment.