Skip to content

Commit

Permalink
feat: change name of pact-body annotation into pact-request-body (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fiszcz committed Apr 13, 2021
1 parent 364d32c commit 137fdbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ interface Query {
## [X] Create the concept how to get information about request body of interaction

```ts
function addComment(/** @pact-body */ newComment: NewComment) {
function addComment(/** @pact-request-body */ newComment: NewComment) {
// ...
}

Expand All @@ -271,7 +271,7 @@ or

```ts
function addComment(postId: string, commentContent: string) {
/** @pact-body */
/** @pact-request-body */
const newComment = {
postId,
commentContent,
Expand Down
6 changes: 3 additions & 3 deletions example/src/api/secondProvider/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export const postsApi = {
* @pact-path /api/clients/10/posts
* @pact-method POST
*/
addNewPost: async function (clientNumber: string, /** @pact-body */ newPost: NewPost) {
addNewPost: async function (clientNumber: string, /** @pact-request-body */ newPost: NewPost) {
const url = endpoint(clientNumber);
/** @pact-body */
/** @pact-request-body */
const body = {newPost};
return axios.post(url, newPost);
},
Expand All @@ -37,7 +37,7 @@ export const postsApi = {
*/
addNewPersonalPost: async function (clientNumber: string, newPost: NewPost) {
const url = endpoint(clientNumber);
/** @pact-body */
/** @pact-request-body */
const body = {personalPost: newPost};
return axios.post(url, body);
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pact-gen-ts",
"version": "0.2.0",
"version": "0.3.0",
"description": "Generating pact files from typescript definitions",
"keywords": [
"pacts",
Expand Down
4 changes: 2 additions & 2 deletions src/core/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const getParameterOfRequestBody = (parameters: tsMorph.ParameterDeclaration[]) =
.getFirstChildByKind(ts.SyntaxKind.JSDocComment)
?.getFirstChildByKind(ts.SyntaxKind.JSDocTag)
?.getFirstChildByKind(ts.SyntaxKind.Identifier);
if (jsDocIdentifierNode?.getText() === 'pact-body') {
if (jsDocIdentifierNode?.getText() === 'pact-request-body') {
return parameter;
}
}
Expand All @@ -171,7 +171,7 @@ const getRequestBodyVariable = (bodyOfFunction: tsMorph.Block) => {
const pactBodyJsDoc = bodyOfFunction.getDescendantsOfKind(ts.SyntaxKind.JSDocComment).find((jsDocComment) => {
return (
jsDocComment.getFirstChildByKind(ts.SyntaxKind.JSDocTag)?.getFirstChildByKind(ts.SyntaxKind.Identifier)?.getText() ===
'pact-body'
'pact-request-body'
);
});
if (pactBodyJsDoc) {
Expand Down

0 comments on commit 137fdbe

Please sign in to comment.