0.6.3 • Published 4 months ago

serverless-wso2-apim v0.6.3

Weekly downloads
124
License
MIT
Repository
github
Last release
4 months ago

serverless-wso2-apim

Serverless Framework plugin to manage APIs on WSO2 API Manager.

img

Compatible with

Features

  • Create, Update and Publish your API definitions via sls deploy.
  • Manage your API definitions via sls info and sls remove.
  • Supports HTTP and JMS backends with mediation policies & additional API properties.
  • Uploads backend certificates (including CAs) to enable HTTP/s connectivity with backends.
  • Supports Swagger 2.0 and OpenAPI 3.0 specifications and will publish them to WSO2 Store / Dev Portal.
  • Automatically detects the version of WSO2 API Manager running.

Install Plugin

  • Discover it on npmjs.com @ here

  • yarn add -D serverless-wso2-apim or npm install --save serverless-wso2-apim

  • Then in serverless.yml add following entry to the plugins array:

    plugins:
      - serverless-wso2-apim

Using the Plugin

  • Make sure you have a Serverless project set up as described here.

  • Add configuration options to your Serverless configuration, as below.

    custom:
      wso2apim:
        enabled: true
        host: "wso2-apimanager.com"
        port: 443
        user: "user@tenant"
        pass: "password"
        gatewayEnv: "Production and Sandbox"
  • Add one or more API definitions to your Serverless configuration, as below.

    serverless.yml:

    custom:
      wso2apim:
        apidefs:
          - myAwesomeAPI: # Your API Definition Identifier
            name: "MyAwesomeAPI" # (CANNOT BE UPDATED LATER) Your API Name
            version: "v1" # (CANNOT BE UPDATED LATER) Your API Version, which also forms a part of the API URL ultimately
            rootContext: "/myawesomeapi" # (CANNOT BE UPDATED LATER) Your API Context, which will be exposed by WSO2 API Gateway. Must be unique per Gateway Environment.
            description: "My Awesome API"
            visibility: "PUBLIC"
            backend:
              http: # HTTP-based Backends
                baseUrl: "https://backend:port/123"
                certChain: "file://certs/backend.cer"
            mediationPolicies: # Optional
              in: "log_in_message"
              out: "None"
              fault: "None"
            apiProperties: # Optional
              "property1": "value1"
              "property2": "value2"
            maxTps: 100
            tags:
              - my-awesome-api
              - awesomeness
            swaggerSpec: # Swagger 2.0 / OpenAPI 3.0 specification in YML
  • Run sls deploy to create-and-publish (or) update-and-republish API definitions (and associated backend certificates, if supplied) in WSO2 API Manager.

  • Run sls info to view the status of API deployment on WSO2 API Manager.

  • Run sls remove to delete API definitions (and associated backend certificates, if exists) when there are no active subscriptions exist on those APIs.

Configuration Reference

custom.wso2apim.*

ParameterWhat?Usage Example
enabledDefault is true. When set to false explicitly, deployment of APIs on WSO2 will be skipped. Suitable for offline testing etc.true
hostWSO2 API Manager Hostnamewso2-apimanager.com
portWSO2 API Manager Port443
userUsername with an optional tenant symbol.user@tenant
passPassword, supports Serverless Variables syntax.xxx
gatewayEnvTarget gateway environment, as configured in your WSO2 installation.Production and Sandbox

custom.wso2apim.apidefs.<Your-API>.*

ParameterWhat?Usage Example
name(CANNOT BE UPDATED LATER) Your API NameMyAwesomeAPI
version(CANNOT BE UPDATED LATER) Your API Version, which also forms a part of the API URL ultimately.v1
rootContext(CANNOT BE UPDATED LATER) Your API Context, which will be exposed by WSO2 API Gateway. Must be unique per Gateway Environment./myawesomeapi
descriptionFree-form textMy Awesome API
visibilitySupports PUBLIC (Visible to everyone) and PRIVATE (Visible to current tenant). Kept in the api for backwards compatibility. Please use fields for subscriberVisibility and publisherVisibility.PUBLIC
subscriberVisibilityVisibility of the API in the developer portal. Supports PUBLIC (Visible to everyone) and PRIVATE (Visible to current tenant) and RESTRICTED (Visible to it's tenant domain and only to the user roles that you specify. You should provide the roles in the subscriberVisibilityRoles.).RESTRICTED
subscriberVisibilityRolesThe user roles that are able to access the API in Store. Only applicable in combination with subscriberVisibility.admin
publisherVisibilityVisibility of the API in the publisher portal. Supports PRIVATE (Visible to all logged in publishers/creators) and RESTRICTED (Visible to logged in publishers/creators with the roles that you specify. You should provide the roles in the publisherVisibilityRoles.).RESTRICTED
publisherVisibilityRolesThe user roles that are able to access the API in Store. Only applicable in combination with publisherVisibility.admin
backendSupports http and jms backends. Note: One API definition supports only one backend.
backend.http.baseUrlYour HTTP backend base URL. It supports: a. URL - Any valid HTTP URL. b. AWS CloudFormation Export - Exported value must contain a valid HTTP URL.https://backend:port/123 (or) !ImportValue xx
backend.http.certChainOptional, your backend certificate chain in PEM (base64) format. It supports: a. File system - Path must be relative to where serverless.yml is located. b. AWS Certificate ARN c. AWS CloudFormation Export - Exported value must contain a valid AWS Certificate ARN.file://certs/backend.cer (or) arn:aws:acm:.. (or) !ImportValue xx
backend.jms.destinationYour JMS Destination (queue or topic name)MY.BACKEND.TOPIC
backend.jms.parametersList of JMS connection parameters to be used in key:value form as described here.transport.jms.ConnectionFactory: 'My-ConnectionFactory'
backend.endpointTypeOptional, defaults to http. If you are using a non standard WSO2 extension, you might want to be able to override this.http, jms, lambda
securitySchemeOptional, defaults to oath2. Supports mutualssl and oauth2. .
securityScheme.mutualsslRequires securityScheme.mutualssl.enabled and securityScheme.mutualssl.clientCert to be defined. .
securityScheme.mutualssl.clientCertRequired with mutualssl, your client certificate chain in PEM (base64) format. It supports: a. File system - Path must be relative to where serverless.yml is located. b. AWS Certificate ARN c. AWS CloudFormation Export - Exported value must contain a valid AWS Certificate ARN.file://certs/backend.cer (or) arn:aws:acm:.. (or) !ImportValue xx
securityScheme.mutualssl.enabledRequired with securityScheme.mutualssl. Expects true or false .
securityScheme.oauth2Requires securityScheme.oauth2.enabled to be defined. .
securityScheme.oauth2.enabledRequired with securityScheme.oauth2. Expects true or false .
mediationPoliciesOptional, your choice of mediation policies (or) sequences. They can manipulate input/output/fault messages as described here.
mediationPolicies.inInput mediation policy, it manipulates the request going to your backend.log_in_message
mediationPolicies.outOutput mediation policy, it manipulates the response going back to your API consumer.json_validator
mediationPolicies.faultFault mediation policy, it manipulates the fault handling.None
apiPropertiesOptional, List of API properties to be used in key:value form as described here.'property1': 'value1'
maxTpsMax. Transactions per second, used for throttling.100
corsOptional, a CORS configuration to enable. Omit this property to disable CORS. See below for properties.
cors.originsString array of allowed origins. Default: ['*']
cors.headersString array of allowed headers. Default: ['Authorization', 'Access-Control-Allow-Origin', 'Content-Type', 'SOAPAction']
cors.methodsString array of allowed methods. Default: ['GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'OPTIONS']
cors.credentialsAllow credentials (boolean). Default: falsetrue
tagsTags as an array that show up in WSO2 console.
businessInformationOptional, business contact information to the APIs. When specified, it will overwrite the values specified in swaggerSpec.info.contact.email and swaggerSpec.info.contact.name properties
businessInformation.businessOwnerOptional, business owner name
businessInformation.technicalOwnerOptional, technical owner name
businessInformation.businessOwnerEmailOptional, business owner email
businessInformation.technicalOwnerEmailOptional, technical owner email
swaggerSpecSwagger 2.0 / OpenAPI 3.0 specification in YML

💡Tip : Organize your project files efficiently.

You can spread the configuration across multiple files, so you can manage it better. Bonus, you can use linters and validators effectively on your swaggerSpec.

serverless.yml:

custom:
  wso2apim:
    apidefs:
      - ${file('./myAwesomeAPI.yml')}

myAwesomeAPI.yml:

name: "MyAwesomeAPI"
version: "v1"
rootContext: "/myawesomeapi"
---
swaggerSpec: ${file(./myAwesomeAPI.swagger.yml)}

myAwesomeAPI.swagger.yml:

openapi: 3.0.0
info:
  contact:
    name: The Awesome Team
    email: xx@xx.com
paths:
  /pet:
    post:
      summary: Add a new pet to the store
      responses:
        "201":
          description: Pet created
        "405":
          description: Invalid input

What's coming up?

Need Help?

  • Create an issue here

License

MIT

0.6.3

4 months ago

0.6.3-alpha.0

4 months ago

0.6.2-alpha.2

6 months ago

0.6.2-alpha.1

6 months ago

0.6.2-alpha.0

6 months ago

0.6.2

6 months ago

0.6.1

11 months ago

0.6.0-alpha.0

1 year ago

0.6.1-alpha.0

1 year ago

0.6.1-alpha.1

1 year ago

0.5.7-alpha.1

1 year ago

0.5.7-alpha.0

1 year ago

0.6.0

1 year ago

0.5.6-alpha.0

2 years ago

0.5.6

2 years ago

0.5.5-alpha.0

3 years ago

0.5.4-alpha.0

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0-alpha.2

3 years ago

0.5.0

3 years ago

0.5.0-alpha.1

3 years ago

0.5.0-alpha.0

3 years ago

0.4.1-alpha.0

3 years ago

0.4.2-alpha.0

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago

0.1.1

4 years ago

0.0.2-alpha.2

4 years ago

0.0.2-alpha.3

4 years ago

0.0.2-alpha.5

4 years ago

0.0.2-alpha.1

4 years ago

0.0.1-alpha.0

4 years ago

0.0.1-alpha.1

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago