Reconsider API specification #23

Open
opened 11 months ago by inga-lovinde · 0 comments
Owner

Currently, commission method is declared as

  @Post()
  @UsePipes(new BodyValidationPipe(transactionBodySchema))
  async commission(
    @Body() transactionInput: TransactionInput,
  ): Promise<string> {
    return JSON.stringify({
      amount: (await this.getCommissionAmount(transactionInput)).toFixed(2),
      currency: Currency.EUR,
    });
  }

It returns a serialized string instead of an object (which would let NestJS to do the serialization, to set the correct content-type, and to maybe also generate a more informative OpenAPI specification).

There seems to be no reason for it to do that.

Currently, `commission` method is declared as ``` @Post() @UsePipes(new BodyValidationPipe(transactionBodySchema)) async commission( @Body() transactionInput: TransactionInput, ): Promise<string> { return JSON.stringify({ amount: (await this.getCommissionAmount(transactionInput)).toFixed(2), currency: Currency.EUR, }); } ``` It returns a serialized string instead of an object (which would let NestJS to do the serialization, to set the correct content-type, and to maybe also generate a more informative OpenAPI specification). There seems to be no reason for it to do that.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: inga-lovinde/test-assignment-payments#23
Loading…
There is no content yet.