Swagger AEM OSGI
Swagger AEM OSGI is an OpenAPI specification for configuring Adobe Experience Manager (AEM) API.
This specification is used to generate client libraries for Ruby, Python, JavaScript and Java using OpenAPI Generator, with the build and release targets of Swaggy C.
Learn more about Swagger AEM OSGI:
- Installation
- Usage
- Testing
- Frequently Asked Questions
- Versions History
- Presentations
Swagger AEM OSGI is part of AEM OpenCloud platform but it can be used as a stand-alone.
Installation
Requirements
The Swaggy C targets in Makefile generate the clients with the
OpenAPI Generator Docker image, so they need Docker,
plus Node.js, Python and Ruby to build and test the clients. CI runs them in the
cliffano/studio Docker image.
The Java targets in Makefile-extras need Java and Apache Maven. Run them inside the
aem-platform-buildenv Docker image, as CI does.
Download
Each release publishes every client with the same version:
| Language | Package | Getting Started |
|---|---|---|
| Ruby |
swagger_aem_osgi |
README |
| Python |
swaggeraemosgi |
README |
| JavaScript |
node-swagger-aem-osgi |
README |
| Java |
com.shinesolutions:swaggeraemosgi4j |
README |
The API documentation is published to GitHub Pages.
Build from source
The specification is specification/swagger-aem-osgi.yml. Each client is generated into
clients/<language>/generated using its clients/<language>/conf.json.
| Target | Description |
|---|---|
make deps |
Pull the OpenAPI Generator Docker image and install the documentation tools |
make init-spec |
Copy the specification to stage/specification.yml, with the contact details from swaggy-c.yml
|
make generate-primary |
Generate the JavaScript, Python and Ruby clients |
make generate |
Generate all clients, including Java. Run by the Generate API Clients workflow, which commits the result |
make build-javascript, build-python, build-ruby
|
Build a generated client |
make doc |
Generate the API documentation into stage/gh-pages/api/latest
|
make -f Makefile-extras build-java |
Package the committed Java client in clients/java/generated without running tests |
make clean |
Remove stage/ and the generated clients |
$ make clean deps init-spec generate-primary build-ruby
The Java client is only regenerated by make generate. The Java targets build, test and publish the committed
client as it is.
Usage
See the Getting Started README of each client above, and the examples in examples for calling AEM with the JavaScript, Python and Ruby clients.
Testing
| Target | Description |
|---|---|
make ci |
Clean, download dependencies, generate, build and test the JavaScript, Python and Ruby clients, then generate all clients and the API documentation. Run by the CI workflow |
make test-javascript, test-python, test-ruby
|
Build a client, then run its generated unit tests and the tests in test/<language>
|
make test-examples |
Run the client examples in examples |
make -f Makefile-extras test-java |
Run the generated unit tests of the committed Java client |
Unit tests are generated by OpenAPI Generator along with the client code. The tests in test stub the HTTP calls, so they need no AEM instance.
Frequently Asked Questions
-
Q: How can I generate a new OpenAPI specification ?
A: To generate a new OpenAPI specification e.g. when there is a new release of AEM you simply can run the tool
api_generator.rb.Usage:
# ruby tools/openapi_spec_generator.rb --in templates/api.yml --out conf/api.yml' -
Q: How can I define a custom AEM host, user and password to generate OpenAPI Spec file ?
A: To run the OpenAPI Spec generator against a defined AEM Host or to define your own username and password to authenticate against AEM you need to define them as environment variables
usage:
aem_verify_ssl=false
aem_protocol=https \
aem_host=author.sandpit.aemopencloud.net \
aem_port=443 \
aem_username=admin \
aem_password=admin \
ruby tools/openapi_spec_generator.rb --in templates/api.yml --out conf/api.yml
Versions History
Changes in each version are described in CHANGELOG.md.
Since 2.0.0, the specification and all clients are released together with one version, tagged <version> in git,
e.g. 2.1.0. Versions follow Semantic Versioning: use a major release for breaking changes,
minor for new features and patch for fixes. Between releases, the version files hold the next pre-release version,
e.g. 2.1.1-pre.0. Before 2.0.0, the clients were released separately, with tags prefixed by
the language, e.g. ruby-1.0.0 and python-1.0.0.
Versions are managed with RTK, configured in .rtk.json. It sets the release
version in the specification, every clients/<language>/conf.json, the Java client's pom.xml, swaggy-c.yml and
CHANGELOG.md, and sets the publish workflows to check out the tag. It commits and tags the release, then commits the
next pre-release version with the publish workflows back on main.
Release targets
| Target | Description |
|---|---|
make release-major, release-minor, release-patch
|
Release the next major, minor or patch version with RTK. Commits and tags <version> locally; push with git push --follow-tags
|
make publish-javascript, publish-python, publish-ruby
|
Build a client and publish it to npm, PyPI or RubyGems. Run by the Publish JavaScript, Publish Python and Publish Ruby workflows on a pushed tag |
make -f Makefile-extras publish-java |
Sign the committed Java client and upload it to the Maven Central Portal. Run by the Publish Java workflow on a pushed tag |
make -f Makefile-extras publish-java-test |
Sign the Java client and upload it to the Maven Central Portal as a pre-release test version without publishing it, then print the deployment ID for publish-java-status and publish-java-drop. Uploads the current version with -rc.0, such as 2.1.1-rc.0 for 2.1.1-pre.0
|
make -f Makefile-extras publish-java-status DEPLOYMENT_ID=<id> |
Show a Maven Central Portal deployment's state (e.g. VALIDATED, PUBLISHED, FAILED) and errors, using MAVEN_CENTRAL_USERNAME and MAVEN_CENTRAL_PASSWORD
|
make -f Makefile-extras publish-java-drop DEPLOYMENT_ID=<id> |
Drop (delete) a Maven Central Portal deployment that has not been published |
Release requirements
The publish workflows hold the credentials, so a release from GitHub Actions needs none locally. To publish the Java client yourself, you need:
-
A GPG key for signing, with its public key on a keyserver such as
keyserver.ubuntu.com(Maven Central verifies signatures against it) -
A Maven Central Portal user token for the
com.shinesolutionsnamespace -
Both are read from environment variables only, never from files. Enter them in your shell, so the values stay hidden and out of your shell history:
# GPG private key: run this, paste the whole key including the # -----BEGIN/END PGP PRIVATE KEY BLOCK----- lines, press Enter, then Ctrl-D $ stty -echo; MAVEN_GPG_KEY="$(cat)"; stty echo; export MAVEN_GPG_KEY # GPG passphrase and Central Portal user token: type or paste each value, then press Enter $ read -rs MAVEN_GPG_PASSPHRASE; export MAVEN_GPG_PASSPHRASE $ read -rs MAVEN_CENTRAL_USERNAME; export MAVEN_CENTRAL_USERNAME $ read -rs MAVEN_CENTRAL_PASSWORD; export MAVEN_CENTRAL_PASSWORD
Run the Java targets in aem-platform-buildenv, from this repository's directory. It passes the variables through by name:
$ docker run --rm -it -v "$(pwd)":/workspace/swagger-aem-osgi -w /workspace/swagger-aem-osgi \
-e MAVEN_GPG_KEY -e MAVEN_GPG_PASSPHRASE -e MAVEN_CENTRAL_USERNAME -e MAVEN_CENTRAL_PASSWORD \
shinesolutions/aem-platform-buildenv:6.5.0 bash
Release steps
-
Start from an up-to-date
mainwith a green CI build and a clean working tree. Check that the## Unreleasedentries in CHANGELOG.md describe everything in this release. -
Optionally, check signing and the Maven Central upload of the Java client without publishing it:
$ make -f Makefile-extras publish-java-testThen drop the test deployment with
publish-java-drop. The upload counts towards the organisation's Maven Central publishing limits. -
Create the release, either:
- In GitHub Actions, run the Release Major, Release Minor or Release Patch workflow.
It runs RTK and pushes the commits and the tag. Then
git pull --tagsto fetch them. - Or locally with RTK installed, choosing
release-major,release-minororrelease-patch:$ make release-minor $ git push --follow-tags
- In GitHub Actions, run the Release Major, Release Minor or Release Patch workflow.
It runs RTK and pushes the commits and the tag. Then
-
The pushed tag triggers the publish workflows:
Workflow Publishes to Publish API Documentation GitHub Pages Publish JavaScript npm Publish Python PyPI Publish Ruby RubyGems Publish Java Maven Central, with the SHINEOPENSOURCE_MVNREPOSITORY_TOKEN_USERNAME,SHINEOPENSOURCE_MVNREPOSITORY_TOKEN_PASSWORD,SHINEOPENSOURCE_MAVEN_GPG_KEYandSHINEOPENSOURCE_MAVEN_GPG_PASSPHRASEGitHub secretsTo upload the Java client yourself instead, in aem-platform-buildenv:
$ git checkout <version> $ make -f Makefile-extras build-java test-java publish-java $ git checkout main -
Publish the Java client on Maven Central. Maven Central validates the upload (signatures, checksums, POM, sources and javadoc), then the deployment waits at central.sonatype.com → Publishing → Deployments: click Publish to release it, or Drop to discard it without publishing. A published version can't be changed or removed. Without a Central Portal login, use the user token and the deployment ID printed by
publish-java:$ make -f Makefile-extras publish-java-status DEPLOYMENT_ID=<id> $ make -f Makefile-extras publish-java-drop DEPLOYMENT_ID=<id> -
Unset the secrets when you are done:
unset MAVEN_GPG_KEY MAVEN_GPG_PASSPHRASE MAVEN_CENTRAL_USERNAME MAVEN_CENTRAL_PASSWORD