Merge pull request #13558 from pedrolopes9-7/BAEL-6224
BAEL-6224: API First-Development in Spring Boot
This commit is contained in:
commit
768a7800ba
|
@ -112,6 +112,7 @@
|
|||
<configuration>
|
||||
<skipValidateSpec>true</skipValidateSpec>
|
||||
<inputSpec>${project.basedir}/src/main/resources/static/event.yaml</inputSpec>
|
||||
<inputSpec>${project.basedir}/src/main/resources/static/account_api_description.yaml</inputSpec>
|
||||
<generatorName>spring</generatorName>
|
||||
<configOptions>
|
||||
<java8>true</java8>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.baeldung.apifirstdevelopment.controller;
|
||||
|
||||
import org.openapitools.api.AccountApi;
|
||||
import org.openapitools.model.Account;
|
||||
import org.openapitools.model.DepositRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
public class AccountController implements AccountApi {
|
||||
@Override
|
||||
public ResponseEntity<Void> depositToAccount(DepositRequest depositRequest) {
|
||||
//Execute the business logic through Service/Utils/Repository classes
|
||||
return AccountApi.super.depositToAccount(depositRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Account> getAccount() {
|
||||
//Execute the business logic through Service/Utils/Repository classes
|
||||
return AccountApi.super.getAccount();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Banking API Specification for account interoperations
|
||||
description: |-
|
||||
A simple banking API that allows two operations:
|
||||
- get account balance given account number
|
||||
- deposit amount to a account
|
||||
version: 1.0-SNAPSHOT
|
||||
servers:
|
||||
- url: https://testenvironment.org/api/v1
|
||||
- url: https://prodenvironment.org/api/v1
|
||||
tags:
|
||||
- name: accounts
|
||||
description: Operations for bank accounts
|
||||
|
||||
paths:
|
||||
/account:
|
||||
get:
|
||||
tags:
|
||||
- accounts
|
||||
summary: Get account information
|
||||
description: Get account information using account number
|
||||
operationId: getAccount
|
||||
responses:
|
||||
200:
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Account'
|
||||
404:
|
||||
description: Account not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AccountNotFoundError'
|
||||
/account/deposit:
|
||||
post:
|
||||
tags:
|
||||
- accounts
|
||||
summary: Deposit amount to account
|
||||
description: Initiates a deposit operation of a desired amount to the account specified
|
||||
operationId: depositToAccount
|
||||
requestBody:
|
||||
description: Account number and desired amount to deposit
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DepositRequest'
|
||||
required: true
|
||||
responses:
|
||||
204:
|
||||
description: Success
|
||||
404:
|
||||
description: Account not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AccountNotFoundError'
|
||||
components:
|
||||
schemas:
|
||||
Account:
|
||||
type: object
|
||||
properties:
|
||||
balance:
|
||||
type: number
|
||||
AccountNotFoundError:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
DepositRequest:
|
||||
type: object
|
||||
properties:
|
||||
accountNumber:
|
||||
type: string
|
||||
depositAmount:
|
||||
type: number
|
Loading…
Reference in New Issue