/
External API / Open API

External API / Open API

외부 연동에 제공되는 External API, Open API 작성 가이드

“ LogicRepository Schema 사용 사례 위주 “

 

“아래 모든 Sample API에 대하여 POSTMAN Test API Collection 에 정의해두었습니다.
POSTMAN에서 import하여 참조해주세요.”
- backendcore : postman/collection/Test API.postman_collection.json

 

 

 

External API

외부 또는 레거시 시스템과 연동을 위해서 사용하는 API

external API는 자동 생성 API와 설정형 API를 사용할 수 있다.

 

자동 생성 API

{{protocol}}://{{hostname}}:{{port}}/ext/{{nodeType}}/{{event}}

  • nodeType을 만들면 create, update, delete, list, read API를 기본적으로 사용 가능

get {{protocol}}://{{hostname}}:{{port}}/ext/sampleLogicMybatis/list

get {{protocol}}://{{hostname}}:{{port}}/ext/sampleLogicMybatis/read

POST {{protocol}}://{{hostname}}:{{port}}/ext/sampleLogicMybatis/create

POST {{protocol}}://{{hostname}}:{{port}}/ext/sampleLogicMybatis/update

POST {{protocol}}://{{hostname}}:{{port}}/ext/sampleLogicMybatis/delete

 

설정 API

{{protocol}}://{{hostname}}:{{port}}/ext/{{apiCategory}}/{{api}}

 

1. apiCategory 설정

src/main/resources/schema/test/testExternalApi.json
{ "typeId": "apiCategory", "id": "testExternalApi", "categoryName": "Test API", "apiType": "external", "dateFormat": "yyyy-MM-dd HH:mm:ss", "fileUrlFormat": { "default": "{{:getEnvValue('core.cluster.api-url-prefix')}}" }, "commonParameters": [ { "parameter": "apiKey", "required": false } ], "commonResponse": [ ] }

 

2. api 설정 (query 형)

  • 속성정의 : api / apiConfig

    • apiType : external

    • method : POST, GET, PUT, DELETE, PATCH

    • parameters : 필수 request Parameter 설정을 할 수 있다.

아래 사례는 sampleLogicMybatis logic형 NodeType의 “LIST” API 설정이다.

- method : GET

- apiType : external

- parameter : title 필수

sampleLogicMybatisService.list 의 응답결과를 반환

src/main/resources/schema/test/testExternalApi.json
{ "typeId": "api", "category": "testExternalApi", "apiId": "testList", "apiName": "test LIST API (Sample External)", "method": "GET", "apiType": "external", "parameters": [ { "parameter": "title", "name": "Title", "valueType": "STRING", "required": true }, { "parameter": "price", "name": "Price", "valueType": "NUMBER", "required": false } ], "statistic": true, "aggregation": true, "config": [ { "configId": "root", "tid": "sampleLogicMybatis", "type": "query", "allowParams": false, "orderNo": 1, "response": [ { "field": "all", "type": "all" } ] } ] }

 

3. api 설정 (read 형)

  • 속성정의 : api / apiConfig

    • apiType : external

    • method : POST, GET, PUT, DELETE, PATCH

    • parameters : 필수 request Parameter 설정을 할 수 있다.

아래 사례는 sampleLogicMybatis logic형 NodeType의 “READ” API 설정이다.

- method : GET

- apiType : external

- parameter : id 필수

sampleLogicMybatisService.read 의 응답결과를 반환

src/main/resources/schema/test/testExternalApi.json
{ "typeId": "api", "category": "testExternalApi", "apiId": "testRead", "apiName": "test READ API (Sample External)", "method": "GET", "apiType": "external", "parameters": [ { "parameter": "id", "name": "ID", "valueType": "NUMBER", "required": true } ], "statistic": true, "aggregation": true, "config": [ { "configId": "root", "tid": "sampleLogicMybatis", "type": "read", "resultType": "OBJECT", "allowParams": false, "orderNo": 1, "response": [ { "field": "all", "type": "all" } ] } ] }

 

4. api 설정 (event 형)

아래 사례는 sampleLogicMybatis logic형 NodeType의 “EVENT” API 설정이다.

- method : POST

- apiType : external

- parameter : title 필수

config 의 tid : sampleLogicMybatis schema에 선언된 event : testEvent 를 호출하여

(sampleLogicMybatisSchema에 미리 설정한 event : testEvent)

actionBody : sampleLogicMybatisService.testEventMethod 의 응답결과를 반환

src/main/resources/schema/test/testExternalApi.json

event 설정

tid : sampleLogicMybatis schema에 event : testEvent 이벤트 추가

"actionBody": "sampleLogicMybatisService.testEventMethod" 를 실행할 eventAction 설정

/Users/jjong/IdeaProjects/backendcore/src/main/resources/schema/test/sampleLogicMybatisSchema.json

 

 

 

 

Open API

Open API 유형은 자동 생성 API를 사용할 수 없다. 설정 API 만 사용 가능하다.

apiKey 인증이 필요하기 때문에 Open API는 항상 연동시스템에게 부여한 apiKey를 포함하여 호출이 필요하다.

apiKey 없이 호출한 Open API Respose

 

 

apiKey 발행

POSTMAN Collection 참조
/postman/collection/Test API.postman_collection.json

 

  • apiKey Create API로 생성

POST {{protocol}}://{{hostname}}:{{port}}/node/apiKey/create.json

 

  • 발행한 API 조회

get {{protocol}}://{{hostname}}:{{port}}/node/apiKey/list.json

 

 

 

설정 API

{{protocol}}://{{hostname}}:{{port}}/api/{{apiCategory}}/{{api}}?apiKey=XXXXXX

 

API를 설정하는 방식은 External API 의 설정방식과 동일하다.

apiType 만 open 으로 세팅하면 된다.


1. apiCategory 설정

src/main/resources/schema/test/testOpenApi.json

 

2. api 설정 (query 형)

 

3. api 설정 (event 형)

 

Related content

api
More like this
apiCategory
apiCategory
Read with this
자동 생성 API
자동 생성 API
More like this
apiType
Read with this
설정 API
설정 API
More like this
Schema
Read with this