CAPM Open API Framework |
---|
Part 1 – Empowering SAP BTP CAP Services through Open API Spec and Annotations for Effective Communi... Agenda : Recognize the Significance of Standardized and Consistent API Documentation for the CAPM Service (This Blog) |
Part 2 – Empowering SAP BTP CAP Services through Open API Spec and Annotations for Effective Communi... Agenda : CAPM Open API Documentation: Implementation and Development Approach |
Part 3 – Empowering SAP BTP CAP Services through Open API Spec and Annotations for Effective Communi... Agenda: Let’s take a deep dive with annotations & elevate CAPM API documentation to the next level. |
These CDS Modelling layer are enriched by Annotations. Services metadata has been generated based on the CDS Modeling Layer & Annotations.
"Open API Framework generates the Rich Open API Framework based on the CDS Data Model and Annotations."
The diagram below provides a helpful visual representation that gives us a clear understanding of the information discussed above.
// Important Note:
// Use npm add --save-dev cds-swagger-ui-express for Local BAS Testing without production deployment
npm install cds-swagger-ui-express
const cds = require ('@sap/cds')
module.exports = cds.server
const cds_swagger = require ('cds-swagger-ui-express')
cds.on ('bootstrap', app => app.use (cds_swagger()) )
namespace openapi.db;
using {
cuid,
temporal,
Currency
} from '@sap/cds/common';
//Type Declaration
type Guid : String(32);
type AmountT : Decimal(15, 2) @(
Semantics.amount.CurrencyCode: 'CURRENCY_CODE',
sap.unit : 'CURRENCY_CODE'
);
define type Amount {
Currency : Currency;
GrossAmount : AmountT;
NetAmount : AmountT;
}
entity Businesspartner {
key BusinesspartnerGuid : Guid;
BP_Role : String(2);
Email : String(64);
MobileNumber : String(14);
AdressGuid : Association to Address;
BP_ID : String(16);
ComppanyName : String(80);
}
entity Address {
key AdressGuid : Guid;
City : String(64);
PostalCOde : String(14);
Street : String(64);
Businesspartner : Association to one Businesspartner
on Businesspartner.AdressGuid = $self;
}
entity Product {
key ProductGuid : Guid;
ProductID : String(28);
ProductType : String(2);
Category : String(32);
Description : localized String(255);
SupplierGUid : Association to Businesspartner;
Price : Amount;
}
entity Purchaseorder : cuid {
PurchaseOrder : String(24);
Businesspartner_Guid : Association to Businesspartner;
Amount : Amount;
Status : String(1);
Items : Composition of many PurchaseOrderItems
on Items.PurchaseOrder = $self;
Note : String(255)
}
entity PurchaseOrderItems : cuid {
PurchaseOrder : Association to Purchaseorder;
ItemNumber : Integer;
ProductGuid : Association to Product;
}
using {openapi.db as openapi} from '../db/data-model';
service CatalogService {
entity PurchaseOrders as projection on openapi.Purchaseorder
entity PurchaseOrderItems as projection on openapi.PurchaseOrderItems;
entity BusinessPartners as projection on openapi.Businesspartner;
entity Addresses as projection on openapi.Address;
entity Products as projection on openapi.Product
}
"scripts": {
"start": "cds-serve"
}"
const cds = require('@sap/cds')
module.exports = cds.server
//Just to demo the value in application log
console.log('process.env.OpenAPISpecSupport', process.env.OpenAPISpecSupport);
// Variable defined in User defined enviroment variable
if (process.env.OpenAPISpecSupport =='true' || process.env.NODE_ENV !== 'production') {
const cds_swagger = require ('cds-swagger-ui-express')
cds.on ('bootstrap', app => app.use (cds_swagger()) )
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |