- 기본 제공 API 등록
- swagger 파일 위치
>> {Install_Dir}/IntegrationServer/instances/default/packages/WmAPIGateway/resources/apigatewayservices
>> https://github.com/SoftwareAG 에서 API Gateway
- APIGatewayServiceManagement.json Swagger 파일로 기본 제공 API 등록



- Postman 에서 호출 테스트
GET 호출 > /rest/apigateway/apis/{apiId}

Response 값 (Json으로 받음)
{"apiResponse": {"api": {"apiDefinition": {"info": {"version": "1.0","title": "API_TEST_008"},"schemes": [],"security": [],"paths": {"/1": {"get": {"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": [],"enabled": true,"scopes": [],"requestBody": {"content": {},"name": "requestBody"}},"scopes": [],"displayName": "1","enabled": true},"/2": {"get": {"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": [],"enabled": true,"scopes": [],"requestBody": {"content": {},"name": "requestBody"}},"scopes": [],"displayName": "2","enabled": true}},"securityDefinitions": {},"definitions": {},"parameters": {},"baseUriParameters": [],"externalDocs": [],"servers": [{"url": "http://192.168.1.48:5555","variables": {}}],"components": {"schemas": {},"responses": {},"parameters": {},"examples": {},"requestBodies": {},"headers": {},"links": {},"callbacks": {}},"type": "rest"},"nativeEndpoint": [{"passSecurityHeaders": true,"uri": "http://192.168.1.48:5555","connectionTimeoutDuration": 0,"alias": false}],"apiName": "API_TEST_008","apiVersion": "1.0","maturityState": "Beta","isActive": false,"type": "REST","owner": "Administrator","policies": ["f937748a-d0bf-4683-b24d-aece37bdef73"],"tracingEnabled": false,"scopes": [],"publishedPortals": [],"creationDate": "2021-04-28 09:21:22 GMT","systemVersion": 1,"gatewayEndpoints": {},"id": "cd0dd4b2-8895-4d48-89b3-0bb09e972648"},"responseStatus": "SUCCESS","gatewayEndPoints": [],"gatewayEndPointList": [{"endpointName": "DEFAULT_GATEWAY_ENDPOINT","endpointDisplayName": "Default","endpoint": "gateway/API_TEST_008/1.0","endpointType": "DEFAULT"}],"versions": [{"versionNumber": "1.0","apiId": "cd0dd4b2-8895-4d48-89b3-0bb09e972648"}]}}
"path" -> /1 , /2 로 설정 해 둔 API
PUT 호출 > /rest/apigateway/apis/{apiId}

Body 값에 GET호출에서 받았던 apiDefinition 정보를 넣어주면 된다.
{"apiDefinition": {"info": {"version": "1.0","title": "API_TEST_008"},"schemes": [],"security": [],"paths": {"/1": {"get": {"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": [],"enabled": true,"scopes": [],"requestBody": {"content": {},"name": "requestBody"}},"scopes": [],"displayName": "1","enabled": true},"/2": {"get": {"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": [],"enabled": true,"scopes": [],"requestBody": {"content": {},"name": "requestBody"}},"scopes": [],"displayName": "2","enabled": true},"/3": {"get": {"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": [],"enabled": true,"scopes": [],"requestBody": {"content": {},"name": "requestBody"}},"scopes": [],"displayName": "2","enabled": true}},"securityDefinitions": {},"definitions": {},"parameters": {},"baseUriParameters": [],"externalDocs": [],"servers": [{"url": "http://192.168.1.48:5555","variables": {}}],"components": {"schemas": {},"responses": {},"parameters": {},"examples": {},"requestBodies": {},"headers": {},"links": {},"callbacks": {}},"type": "rest"},"nativeEndpoint": [{"passSecurityHeaders": true,"uri": "http://192.168.1.48:5555","connectionTimeoutDuration": 0,"alias": false}],"apiName": "API_TEST_008","apiVersion": "1.0","maturityState": "Beta","isActive": false,"type": "REST","owner": "Administrator","policies": ["f937748a-d0bf-4683-b24d-aece37bdef73"],"tracingEnabled": false,"scopes": [],"publishedPortals": [],"creationDate": "2021-04-28 09:21:22 GMT","systemVersion": 1,"gatewayEndpoints": {},"id": "cd0dd4b2-8895-4d48-89b3-0bb09e972648"},"responseStatus": "SUCCESS","gatewayEndPoints": [],"gatewayEndPointList": [{"endpointName": "DEFAULT_GATEWAY_ENDPOINT","endpointDisplayName": "Default","endpoint": "gateway/API_TEST_008/1.0","endpointType": "DEFAULT"}],"versions": [{"versionNumber": "1.0","apiId": "cd0dd4b2-8895-4d48-89b3-0bb09e972648"}]}
"path" 필드에 /3 을 추가 해서 PUT 호출

> 정상적으로 API Resource path가 추가 된 것을 확인
DELETE 호출 > /rest/apigateway/apis/{apiId}
위와 동일하게 apiId 값을 이용하여 api 삭제 가능 단 inActive API 한해서 인 듯
/rest/apigateway/apis/{apiId}/deactivate 를 사용해서 api를 deactive 상태로 만든 후 삭제 또는
forceDelete 파라미터를 사용해서 Delete 호출 시 삭제가 될 것으로 예상 된다.

※ 문제점 정리 + 추가 테스트 할 내용
- API 를 Update ( Resource Path 추가 ) 에서 Body 값에 들어가는
ex )
"/3": {
"get": {
"responses": {},
"mockedResponses": {},
"mockedConditionsBasedCustomResponsesList": [],
"enabled": true,
"scopes": [],
"requestBody": {
"content": {},
"name": "requestBody"
}
},
"scopes": [],
"displayName": "2",
"enabled": true
}
값 하나하나 추가하며 어떤 값들이 들어가는지 구조를 설정 할 필요가 있음
- API Update 시에 API ID 값으로 GET 호출 시도 후 Response로 받은 apiResponses Document 를 수정하여 PUT 호출에 Body로 넣어야 한다는 문제점 -> apiResponses 값을 수정하는 과정이 필요 할 듯 하다.
>> API 상세 설정 되어 있는 Request Body Schema 값
>> API Resource Path에서 확인 가능
>> 이후 이 스키마에 값을 하나 씩 넣어 보며 테스트를 해볼 필요가 있다. (PolicyID값 문제 등 연관)
{
"type": "object",
"properties": {
"apiDefinition": {
"$ref": "#/components/schemas/API"
},
"apiDescription": {
"type": "string"
},
"apiDocuments": {
"type": "array",
"items": {
"type": "string"
}
},
"apiEndpointPrefix": {
"type": "string"
},
"apiGroups": {
"type": "array",
"items": {
"type": "string"
}
},
"apiName": {
"type": "string"
},
"apiVersion": {
"type": "string"
},
"centraSiteURL": {
"type": "string",
"readOnly": true
},
"creationDate": {
"type": "string",
"readOnly": true
},
"gatewayEndpoints": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"id": {
"type": "string"
},
"isActive": {
"type": "boolean",
"readOnly": true
},
"lastModified": {
"type": "string",
"readOnly": true
},
"maturityState": {
"type": "string"
},
"mockService": {
"$ref": "#/components/schemas/MockService"
},
"nativeEndpoint": {
"uniqueItems": true,
"type": "array",
"readOnly": true,
"items": {
"$ref": "#/components/schemas/Endpoint"
}
},
"nextVersion": {
"type": "string",
"readOnly": true
},
"oauth2ScopeName": {
"type": "string"
},
"owner": {
"type": "string",
"readOnly": true
},
"policies": {
"type": "array",
"readOnly": true,
"items": {
"type": "string"
}
},
"portalApiItemIdentifier": {
"type": "string",
"readOnly": true
},
"prevVersion": {
"type": "string",
"readOnly": true
},
"provider": {
"type": "string",
"readOnly": true
},
"publishedPortals": {
"type": "array",
"items": {
"type": "string"
}
},
"publishedToRegistry": {
"type": "boolean"
},
"rootFileName": {
"type": "string",
"readOnly": true
},
"scopes": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Scope"
}
},
"systemVersion": {
"type": "integer",
"format": "int32",
"readOnly": true
},
"tracingEnabled": {
"type": "boolean",
"readOnly": true
},
"type": {
"type": "string"
}
}
}
###### 추가 테스트 Usecase

APIs > Servicemanagement > CreateAPI / UpdateAPI / DeleteAPI
에 들어있는 값들은 기존 기본 API 테스트시 사용하였던 값과 동일한 값
Usecases

Update Body 에 필요 한 정보들이 다 들어있는지 확인할 필요 있음..
다 체크가 된 것은 아닌 거 같긴 한데..
{"restrictViewAsset": false,"id": "{{apiID}}","apiName": "API_with_Scope_Policy","apiVersion": "1.0","apiDescription": "Petstore API with Log Invocation Traffic Monitoring Policy at Scope level","isActive": true,"nativeEndpoint": [{"passSecurityHeaders": true,"uri": "http://petstore.swagger.io/v2","connectionTimeoutDuration": 0,"alias": false},{"passSecurityHeaders": true,"uri": "https://petstore.swagger.io/v2","connectionTimeoutDuration": 0,"alias": false}],"owner": "Administrator","policies": ["{{policyID}}"],"type": "REST","systemVersion": 1,"maturityState": "Beta","apiGroups": null,"scopes": [{"name": "Pet Scope","description": "","policies": ["{{scopePolicyID}}"]}],"apiDocuments": [],"apiDefinition": {"info": {"title": "Swagger Petstore","description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.","version": "1.0.5","termsOfService": "http://swagger.io/terms/","contact": {"email": "apiteam@swagger.io"},"license": {"name": "Apache 2.0","url": "http://www.apache.org/licenses/LICENSE-2.0.html"}},"serviceRegistryDisplayName": "Petstore_1.0.5","servers": [{"url": "https://petstore.swagger.io/v2","variables": {}},{"url": "http://petstore.swagger.io/v2","variables": {}}],"security": [],"securityDefinitions": {"api_key": {"in": "header","name": "api_key","type": "apiKey"},"petstore_auth": {"authorizationUrl": "https://petstore.swagger.io/oauth/authorize","flow": "implicit","scopes": {"read:pets": "read your pets","write:pets": "modify pets in your account"},"type": "oauth2"}},"definitions": {},"externalDocs": [{"description": "Find out more about Swagger","url": "http://swagger.io"}],"parameters": {},"paths": {"/pet": {"displayName": "/pet","enabled": true,"scopes": ["Pet Scope"],"get": {"scopes": [],"enabled": true,"requestBody": {"name": "requestBody","content": {}},"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": []},"put": {"description": "","tags": ["pet"],"summary": "Update an existing pet","operationId": "updatePet","consumes": ["application/json","application/xml"],"produces": ["application/json","application/xml"],"security": [{"petstore_auth": ["write:pets","read:pets"]}],"scopes": [],"enabled": true,"requestBody": {"name": "updatePet","content": {"application/json": {"examples": {},"schema": {"type": "ref","$ref": "#/components/schemas/Pet","ref": "Pet"},"refSchema": "#/components/schemas/Pet"},"application/xml": {"examples": {},"schema": {"type": "ref","$ref": "#/components/schemas/Pet","ref": "Pet"},"refSchema": "#/components/schemas/Pet"}}},"responses": {"400": {"schema": {},"content": {},"examples": {},"headers": {},"description": "Invalid ID supplied","links": {}},"404": {"schema": {},"content": {},"examples": {},"headers": {},"description": "Pet not found","links": {}},"405": {"schema": {},"content": {},"examples": {},"headers": {},"description": "Validation exception","links": {}}},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": []},"post": {"description": "","tags": ["pet"],"summary": "Add a new pet to the store","operationId": "addPet","consumes": ["application/json","application/xml"],"produces": ["application/json","application/xml"],"security": [{"petstore_auth": ["write:pets","read:pets"]}],"scopes": [],"enabled": true,"requestBody": {"name": "addPet","content": {"application/json": {"examples": {},"schema": {"type": "ref","$ref": "#/components/schemas/Pet","ref": "Pet"},"refSchema": "#/components/schemas/Pet"},"application/xml": {"examples": {},"schema": {"type": "ref","$ref": "#/components/schemas/Pet","ref": "Pet"},"refSchema": "#/components/schemas/Pet"}}},"responses": {"405": {"schema": {},"content": {},"examples": {},"headers": {},"description": "Invalid input","links": {}}},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": []}},"/test": {"displayName": "/test","enabled": true,"scopes": [],"get": {"scopes": [],"enabled": true,"requestBody": {"name": "requestBody","content": {}},"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": []},"put": {"scopes": [],"enabled": true,"requestBody": {"name": "requestBody","content": {}},"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": []},"post": {"scopes": [],"enabled": true,"requestBody": {"name": "requestBody","content": {}},"responses": {},"mockedResponses": {},"mockedConditionsBasedCustomResponsesList": []}}},"tags": [{"name": "pet","description": ""}],"components": {"schemas": {"ApiResponse": {"type": "gateway","schema": "{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\"},\"message\":{\"type\":\"string\"},\"type\":{\"type\":\"string\"}}}"},"Category": {"type": "gateway","schema": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\",\"format\":\"int64\"},\"name\":{\"type\":\"string\"}},\"xml\":{\"name\":\"Category\"}}"},"Order": {"type": "gateway","schema": "{\"type\":\"object\",\"properties\":{\"complete\":{\"type\":\"boolean\"},\"id\":{\"type\":\"integer\",\"format\":\"int64\"},\"petId\":{\"type\":\"integer\",\"format\":\"int64\"},\"quantity\":{\"type\":\"integer\",\"format\":\"int32\"},\"shipDate\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"type\":\"string\",\"description\":\"Order Status\",\"enum\":[\"placed\",\"approved\",\"delivered\"]}},\"xml\":{\"name\":\"Order\"}}"},"Pet": {"type": "gateway","schema": "{\"required\":[\"photoUrls\",\"name\"],\"type\":\"object\",\"properties\":{\"category\":{\"$ref\":\"#/components/schemas/Category\"},\"id\":{\"type\":\"integer\",\"format\":\"int64\"},\"name\":{\"type\":\"string\",\"example\":\"doggie\"},\"photoUrls\":{\"type\":\"array\",\"xml\":{\"wrapped\":true},\"items\":{\"type\":\"string\",\"xml\":{\"name\":\"photoUrl\"}}},\"status\":{\"type\":\"string\",\"description\":\"pet status in the store\",\"enum\":[\"available\",\"pending\",\"sold\"]},\"tags\":{\"type\":\"array\",\"xml\":{\"wrapped\":true},\"items\":{\"$ref\":\"#/components/schemas/Tag\",\"xml\":{\"name\":\"tag\"}}}},\"xml\":{\"name\":\"Pet\"}}"},"Tag": {"type": "gateway","schema": "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\",\"format\":\"int64\"},\"name\":{\"type\":\"string\"}},\"xml\":{\"name\":\"Tag\"}}"},"User": {"type": "gateway","schema": "{\"type\":\"object\",\"properties\":{\"email\":{\"type\":\"string\"},\"firstName\":{\"type\":\"string\"},\"id\":{\"type\":\"integer\",\"format\":\"int64\"},\"lastName\":{\"type\":\"string\"},\"password\":{\"type\":\"string\"},\"phone\":{\"type\":\"string\"},\"userStatus\":{\"type\":\"integer\",\"description\":\"User Status\",\"format\":\"int32\"},\"username\":{\"type\":\"string\"}},\"xml\":{\"name\":\"User\"}}"}},"parameters": {},"headers": {},"examples": {},"responses": {},"requestBodies": {},"links": {},"callbacks": {}}}}
multipart/form-data
request body 는 이미 postman에서 확인 가능한...
