MuleSoft Accelerator API Archetype - Source

(0 reviews)

home

This asset is a component of the MuleSoft Accelerators, which are a collection of technical assets (predominantly API specifications and implementation templates) and documentation to accelerate the implementation of multiple use cases supporting a larger business or industry problem.

This Maven archetype is pre-built with Accelerator best practices to help developers kick start their development of new APIs. This will take care of some of the non-functional set up required for every API being built by development teams.

Getting started (local installs only)

This plug-in can been installed to your local Anypoint Exchange instance so it can be used as-is, without having each developer download and install it locally. If adjustments need to be made to the plug-in, however, then follow these steps:

  • Unpack the source project
  • Increment the patch version of the plug-in
  • Run mvn clean install for install to local repository
  • Reference the new version when generating a project

To publish changes to the plugin, do the following:

  • Update the documentation below to reflect the new version number
  • Run mvn clean deploy to deploy to your Exchange repository
  • Check in all changes to a feature branch and raise a pull request

Generating and importing the sample project

Execute the following command in the folder you want the project to be created. If you've installed the plugin to your own Exchange repository, change the archetype group ID accordingly.

Linux/MacOSX

mvn archetype:generate \
-DarchetypeArtifactId=accelerator-mulesoft-api-archetype \
-DarchetypeGroupId=org.mule.examples \
-DarchetypeVersion=2.4.1 \
-DgroupId=<<groupId>> \
-DartifactId=<<artifactId>> \
-Dversion=<<version>> \
-DinteractiveMode=false

Example:
mvn archetype:generate -DarchetypeGroupId="org.mule.examples" \ -DarchetypeArtifactId=accelerator-mulesoft-api-archetype \ -DarchetypeVersion=2.4.1 \ -DgroupId=com.demo \ -DartifactId=demo-sys-api \ -Dversion=1.0.0 \ -DinteractiveMode=false

Windows

mvn archetype:generate -DarchetypeArtifactId="accelerator-mulesoft-api-archetype" -DarchetypeGroupId="org.mule.examples" -DarchetypeVersion="2.4.1" -DgroupId="<<groupId>" -DartifactId="<<artifactId>>" -Dversion="<<version>>" -DinteractiveMode=false

Example:
mvn archetype:generate -DarchetypeGroupId="org.mule.examples" -DarchetypeArtifactId="accelerator-mulesoft-api-archetype" -DarchetypeVersion="2.4.1" -DgroupId="com.demo" -DartifactId="demo-sys-api" -Dversion="1.0.0" -DinteractiveMode=false

Import the newly created project into Studio and get started with the development.

Next steps

  • Replace the API specification from the pom.xml with an appropriate one.
    • Modify the router config to point to the API specification.
    • Scaffold the specification to generate the flows.
    • Rename the generated flow file to remove any unwanted prefix (e.g., com-).
    • Rename the generated flows and config elements to remove any unwanted prefix and the -spec suffix.
    • Remove any global configurations that the project will not use from the global.xml (e.g., the Anypoint MQ config).
  • POM updates
    • Remove any dependencies that the project will not use.
    • Add any deployment properties as needed by the project.
  • Replace or refactor the entities.xml to cater to the needs of use case.
    • All logic should go into this file.
  • Update the MUnit test suite for the /ping endpoint to reference the correct HTTP config element.
  • Update required properties in the config-local.yaml and config-secured-local.yaml files for local runs.
  • Update README.md file as appropriate for the project.

Reviews

TypeCustom
OrganizationMulesoft
Published by
MuleSoft Organization
Published onDec 12, 2023
Asset overview

Asset versions for 2.6.x

Asset versions
VersionActions
2.6.0