@apistudio/apim-cli
Version:
CLI for API Management Products
96 lines (95 loc) • 2.62 kB
JavaScript
/**
* Example usage of the exported schema types
*/
// Example of creating an API using the exported schema type
const createApiExample = () => {
const metadata = {
name: 'example-api',
version: '1.0.0',
description: 'Example API created using exported schema types'
};
const api = {
kind: 'API',
apiVersion: 'api.ibm.com/v1',
metadata,
spec: {
'api-spec': {
$path: '/path/to/api/spec.yaml'
},
'policy-sequence': [
{
$ref: '#/components/schemas/StagedPolicySequence'
}
]
}
};
return api;
};
// Example of creating a Product using the exported schema type
const createProductExample = () => {
const metadata = {
name: 'example-product',
version: '1.0.0',
description: 'Example Product created using exported schema types'
};
const product = {
kind: 'Product',
apiVersion: 'api.ibm.com/v1',
metadata,
spec: {
info: {
summary: 'Example Product',
categories: ['example', 'demo'],
contact: {
name: 'API Team',
email: 'api-team@example.com'
}
},
apis: [
{
$ref: '#/components/schemas/Api/example-api'
}
],
plans: [
{
$ref: '#/components/schemas/Plan/basic-plan'
}
]
}
};
return product;
};
// Example of creating a Plan using the exported schema type
const createPlanExample = () => {
const metadata = {
name: 'basic-plan',
version: '1.0.0',
description: 'Basic plan with rate limiting'
};
const plan = {
kind: 'Plan',
apiVersion: 'api.ibm.com/v1',
metadata,
spec: {
pricing: {
value: 0,
currency: 'USD'
},
isApprovalRequired: false,
qos: {
withRateLimit: [
{
maxRequest: 100,
interval: '1h',
alertConfiguration: 'once',
alertMessage: 'Rate limit reached',
name: 'hourly-limit'
}
]
}
}
};
return plan;
};
export { createApiExample, createProductExample, createPlanExample };
// Made with Bob