-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spike] End to End test Shopping example in cloud with APIConnect #4498
Comments
Since the purpose is to try out the integration instead of testing on different cloud services, I'd suggest we simply use IBM Cloud. It might be easier since we've done that before, and less learning curve there. |
@deepakrkris , while you are doing this, please create an internal document (for the loopback team) of all the steps you had to perform to set this up and test API Connect. Thanks. |
@dhmlau let me try to do some simple tests with IBM cloud and see if it is doable. AWS was much simpler for me. |
@deepakrkris, I'd like to have a proper priority on this task, so I have a few questions:
Thanks. |
Shopping app test is required for:
Todo example comparatively has very less scope for testing. |
Thanks. Let me add it to the acceptance criteria too. |
I have did an end to end test of shopping app (deployed to IBM Cloud, http://184.172.242.157:32719 ) with IBM APIConnect (gateway url : https://kraken-rgw.loki.dev.ciondemand.com/ibm/sandbox).
|
I was able to publish the shopping product in previous example |
original apen-api spec downloaded from the shopping app http://184.172.242.157:32719/openapi.json { "openapi": "3.0.0", "info": { "title": "loopback4-example-shopping", "version": "1.2.0", "description": "LoopBack 4 Example: Online Shopping APIs", "contact": { "name": "LoopBack contributors", "email": "[email protected]", "url": "https://loopback.io" } }, "paths": { "/ping": { "get": { "x-controller-name": "PingController", "x-operation-name": "ping", "tags": [ "PingController" ], "responses": { "200": { "description": "Ping Response", "content": { "application/json": { "schema": { "type": "object", "properties": { "greeting": { "type": "string" }, "date": { "type": "string" }, "url": { "type": "string" }, "headers": { "type": "object", "properties": { "Content-Type": { "type": "string" } }, "additionalProperties": false } } } } } } }, "operationId": "PingController.ping" } }, "/products/count": { "get": { "x-controller-name": "ProductController", "x-operation-name": "count", "tags": [ "ProductController" ], "responses": { "200": { "description": "Product model count", "content": { "application/json": { "schema": { "type": "object", "title": "loopback.Count", "properties": { "count": { "type": "number" } } } } } } }, "parameters": [ { "name": "where", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Product.WhereFilter", "additionalProperties": true } } } } ], "operationId": "ProductController.count" } }, "/products/{id}": { "put": { "x-controller-name": "ProductController", "x-operation-name": "replaceById", "tags": [ "ProductController" ], "security": [ { "jwt": [] } ], "responses": { "204": { "description": "Product PUT success" } }, "parameters": [ { "name": "id", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Product" } } }, "x-parameter-index": 1 }, "operationId": "ProductController.replaceById" }, "patch": { "x-controller-name": "ProductController", "x-operation-name": "updateById", "tags": [ "ProductController" ], "security": [ { "jwt": [] } ], "responses": { "204": { "description": "Product PATCH success" } }, "parameters": [ { "name": "id", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductPartial" } } }, "x-parameter-index": 1 }, "operationId": "ProductController.updateById" }, "get": { "x-controller-name": "ProductController", "x-operation-name": "findById", "tags": [ "ProductController" ], "responses": { "200": { "description": "Product model instance", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductWithRelations" } } } } }, "parameters": [ { "name": "id", "in": "path", "schema": { "type": "string" }, "required": true }, { "name": "filter", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Product.Filter", "properties": { "offset": { "type": "integer", "minimum": 0 }, "limit": { "type": "integer", "minimum": 1, "example": 100 }, "skip": { "type": "integer", "minimum": 0 }, "order": { "type": "array", "items": { "type": "string" } }, "where": { "title": "Product.WhereFilter", "type": "object", "additionalProperties": true }, "fields": { "title": "Product.Fields", "type": "object", "properties": { "productId": { "type": "boolean" }, "name": { "type": "boolean" }, "price": { "type": "boolean" }, "image": { "type": "boolean" }, "description": { "type": "boolean" }, "details": { "type": "boolean" } }, "additionalProperties": false } }, "additionalProperties": false } } } } ], "operationId": "ProductController.findById" }, "delete": { "x-controller-name": "ProductController", "x-operation-name": "deleteById", "tags": [ "ProductController" ], "security": [ { "jwt": [] } ], "responses": { "204": { "description": "Product DELETE success" } }, "parameters": [ { "name": "id", "in": "path", "schema": { "type": "string" }, "required": true } ], "operationId": "ProductController.deleteById" } }, "/products": { "post": { "x-controller-name": "ProductController", "x-operation-name": "create", "tags": [ "ProductController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "Product model instance", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Product" } } } } }, "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewProduct" } } } }, "operationId": "ProductController.create" }, "patch": { "x-controller-name": "ProductController", "x-operation-name": "updateAll", "tags": [ "ProductController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "Product PATCH success count", "content": { "application/json": { "schema": { "type": "object", "title": "loopback.Count", "properties": { "count": { "type": "number" } } } } } } }, "parameters": [ { "name": "where", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Product.WhereFilter", "additionalProperties": true } } } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductPartial" } } } }, "operationId": "ProductController.updateAll" }, "get": { "x-controller-name": "ProductController", "x-operation-name": "find", "tags": [ "ProductController" ], "responses": { "200": { "description": "Array of Product model instances", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/ProductWithRelations" } } } } } }, "parameters": [ { "name": "filter", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Product.Filter", "properties": { "offset": { "type": "integer", "minimum": 0 }, "limit": { "type": "integer", "minimum": 1, "example": 100 }, "skip": { "type": "integer", "minimum": 0 }, "order": { "type": "array", "items": { "type": "string" } }, "where": { "title": "Product.WhereFilter", "type": "object", "additionalProperties": true }, "fields": { "title": "Product.Fields", "type": "object", "properties": { "productId": { "type": "boolean" }, "name": { "type": "boolean" }, "price": { "type": "boolean" }, "image": { "type": "boolean" }, "description": { "type": "boolean" }, "details": { "type": "boolean" } }, "additionalProperties": false } }, "additionalProperties": false } } } } ], "operationId": "ProductController.find" } }, "/shoppingCarts/{userId}/items": { "post": { "x-controller-name": "ShoppingCartController", "x-operation-name": "addItem", "tags": [ "ShoppingCartController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User shopping cart item is created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ShoppingCart" } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "description": "shopping cart item", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ShoppingCartItem" } } }, "x-parameter-index": 1 }, "operationId": "ShoppingCartController.addItem" } }, "/shoppingCarts/{userId}": { "post": { "x-controller-name": "ShoppingCartController", "x-operation-name": "create", "tags": [ "ShoppingCartController" ], "security": [ { "jwt": [] } ], "responses": { "204": { "description": "User shopping cart is created or updated" } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "description": "shopping cart", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ShoppingCart" } } }, "x-parameter-index": 1 }, "operationId": "ShoppingCartController.create" }, "put": { "x-controller-name": "ShoppingCartController", "x-operation-name": "set", "tags": [ "ShoppingCartController" ], "security": [ { "jwt": [] } ], "responses": { "204": { "description": "User shopping cart is created or updated" } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "description": "shopping cart", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ShoppingCart" } } }, "x-parameter-index": 1 }, "operationId": "ShoppingCartController.set" }, "get": { "x-controller-name": "ShoppingCartController", "x-operation-name": "get", "tags": [ "ShoppingCartController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User shopping cart is read", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ShoppingCart" } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "operationId": "ShoppingCartController.get" }, "delete": { "x-controller-name": "ShoppingCartController", "x-operation-name": "remove", "tags": [ "ShoppingCartController" ], "security": [ { "jwt": [] } ], "responses": { "204": { "description": "User shopping cart is deleted" } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "operationId": "ShoppingCartController.remove" } }, "/users/login": { "post": { "x-controller-name": "UserController", "x-operation-name": "login", "tags": [ "UserController" ], "responses": { "200": { "description": "Token", "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string" } } } } } } }, "requestBody": { "description": "The input of login function", "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string", "format": "email" }, "password": { "type": "string", "minLength": 8 } } } } } }, "operationId": "UserController.login" } }, "/users/me": { "get": { "x-controller-name": "UserController", "x-operation-name": "printCurrentUser", "tags": [ "UserController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "The current user profile", "content": { "application/json": { "schema": { "type": "object", "required": [ "id" ], "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "name": { "type": "string" } } } } } } }, "operationId": "UserController.printCurrentUser" } }, "/users/{userId}/orders": { "post": { "x-controller-name": "UserOrderController", "x-operation-name": "createOrder", "tags": [ "UserOrderController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User.Order model instance", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Order" } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Order" } } }, "x-parameter-index": 1 }, "operationId": "UserOrderController.createOrder" }, "patch": { "x-controller-name": "UserOrderController", "x-operation-name": "patchOrders", "tags": [ "UserOrderController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User.Order PATCH success count", "content": { "application/json": { "schema": { "type": "object", "title": "loopback.Count", "properties": { "count": { "type": "number" } } } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true }, { "name": "where", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Order.WhereFilter", "additionalProperties": true } } } } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object" } } }, "x-parameter-index": 1 }, "operationId": "UserOrderController.patchOrders" }, "get": { "x-controller-name": "UserOrderController", "x-operation-name": "findOrders", "tags": [ "UserOrderController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "Array of User's Orders", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Order" } } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true }, { "name": "filter", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Order.Filter", "properties": { "offset": { "type": "integer", "minimum": 0 }, "limit": { "type": "integer", "minimum": 1, "example": 100 }, "skip": { "type": "integer", "minimum": 0 }, "order": { "type": "array", "items": { "type": "string" } }, "where": { "title": "Order.WhereFilter", "type": "object", "additionalProperties": true }, "fields": { "title": "Order.Fields", "type": "object", "properties": { "orderId": { "type": "boolean" }, "date": { "type": "boolean" }, "userId": { "type": "boolean" }, "fullName": { "type": "boolean" }, "total": { "type": "boolean" }, "products": { "type": "boolean" } }, "additionalProperties": false }, "include": { "title": "Order.IncludeFilter", "type": "array", "items": { "title": "Order.IncludeFilter.Items", "type": "object", "properties": { "relation": { "type": "string" }, "scope": { "properties": { "offset": { "type": "integer", "minimum": 0 }, "limit": { "type": "integer", "minimum": 1, "example": 100 }, "skip": { "type": "integer", "minimum": 0 }, "order": { "type": "array", "items": { "type": "string" } }, "where": { "type": "object", "additionalProperties": true }, "fields": { "type": "object", "properties": {}, "additionalProperties": true } }, "additionalProperties": false, "title": "Order.ScopeFilter" } } } } }, "additionalProperties": false } } } } ], "operationId": "UserOrderController.findOrders" }, "delete": { "x-controller-name": "UserOrderController", "x-operation-name": "deleteOrders", "tags": [ "UserOrderController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User.Order DELETE success count", "content": { "application/json": { "schema": { "type": "object", "title": "loopback.Count", "properties": { "count": { "type": "number" } } } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true }, { "name": "where", "in": "query", "content": { "application/json": { "schema": { "type": "object", "title": "Order.WhereFilter", "additionalProperties": true } } } } ], "operationId": "UserOrderController.deleteOrders" } }, "/users/{userId}/recommend": { "get": { "x-controller-name": "UserController", "x-operation-name": "productRecommendations", "tags": [ "UserController" ], "responses": { "200": { "description": "Products", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Product" } } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "operationId": "UserController.productRecommendations" } }, "/users/{userId}": { "put": { "x-controller-name": "UserController", "x-operation-name": "set", "tags": [ "UserController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "description": "update user", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } }, "x-parameter-index": 2 }, "operationId": "UserController.set" }, "get": { "x-controller-name": "UserController", "x-operation-name": "findById", "tags": [ "UserController" ], "security": [ { "jwt": [] } ], "responses": { "200": { "description": "User", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } } }, "parameters": [ { "name": "userId", "in": "path", "schema": { "type": "string" }, "required": true } ], "operationId": "UserController.findById" } }, "/users": { "post": { "x-controller-name": "UserController", "x-operation-name": "create", "tags": [ "UserController" ], "responses": { "200": { "description": "User", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } } }, "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewUser" } } } }, "operationId": "UserController.create" } } }, "servers": [ { "url": "/" } ], "components": { "schemas": { "Product": { "title": "Product", "properties": { "productId": { "type": "string" }, "name": { "type": "string" }, "price": { "type": "number" }, "image": { "type": "string" }, "description": { "type": "string" }, "details": { "type": "string" } }, "required": [ "name", "price" ], "additionalProperties": false }, "NewProduct": { "title": "NewProduct", "description": "(Schema options: { title: 'NewProduct', exclude: [ 'productId' ] })", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "image": { "type": "string" }, "description": { "type": "string" }, "details": { "type": "string" } }, "required": [ "name", "price" ], "additionalProperties": false }, "ProductWithRelations": { "title": "ProductWithRelations", "description": "(Schema options: { includeRelations: true })", "properties": { "productId": { "type": "string" }, "name": { "type": "string" }, "price": { "type": "number" }, "image": { "type": "string" }, "description": { "type": "string" }, "details": { "type": "string" } }, "required": [ "name", "price" ], "additionalProperties": false }, "ProductPartial": { "title": "ProductPartial", "description": "(Schema options: { partial: true })", "properties": { "productId": { "type": "string" }, "name": { "type": "string" }, "price": { "type": "number" }, "image": { "type": "string" }, "description": { "type": "string" }, "details": { "type": "string" } }, "additionalProperties": false }, "ShoppingCartItem": { "title": "ShoppingCartItem", "properties": { "productId": { "type": "string" }, "name": { "type": "string" }, "quantity": { "type": "number" }, "price": { "type": "number" } }, "additionalProperties": false }, "ShoppingCart": { "title": "ShoppingCart", "properties": { "userId": { "type": "string" }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/ShoppingCartItem" } } }, "additionalProperties": false }, "Order": { "title": "Order", "properties": { "orderId": { "type": "string" }, "date": { "type": "string", "format": "date-time" }, "userId": { "type": "string" }, "fullName": { "type": "string" }, "total": { "type": "number" }, "products": { "type": "array", "items": { "$ref": "#/components/schemas/ShoppingCartItem" } } }, "required": [ "products" ], "additionalProperties": false }, "User": { "title": "User", "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "firstName": { "type": "string" }, "lastName": { "type": "string" }, "roles": { "type": "array", "items": { "type": "string" } } }, "required": [ "email" ], "additionalProperties": false }, "NewUser": { "title": "NewUser", "description": "(Schema options: { title: 'NewUser' })", "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "firstName": { "type": "string" }, "lastName": { "type": "string" }, "roles": { "type": "array", "items": { "type": "string" } }, "password": { "type": "string" } }, "required": [ "email", "password" ], "additionalProperties": false }, "NewUserRequest": { "title": "NewUserRequest", "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "firstName": { "type": "string" }, "lastName": { "type": "string" }, "roles": { "type": "array", "items": { "type": "string" } }, "password": { "type": "string" } }, "required": [ "email", "password" ], "additionalProperties": false } }, "securitySchemes": { "jwt": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } } |
I had to edit the original json spec for a very tiny change: adding the mandatory
I also had to change the security scheme type from
|
follow up issue opened for minor change #5259 |
Spike is complete now, acceptance criteria is satisfied. |
Test prerequisites
Make minor modifications to the imported api spec, as per suggestions in spike [Spike] API Connect / LoopBack 4 integration #4115This is no longer needed (hopefully) with the APIC OpenAPI enhancerAcceptance criteria
We should
ensure
:See the specific tests needed in the shopping app tests on top of the todo list app test: #4498 (comment)
cc @raymondfeng @bajtos @dhmlau
The text was updated successfully, but these errors were encountered: