Skip to content

Commit

Permalink
Merge pull request #14 from Backbase/wa3-openapi-integration
Browse files Browse the repository at this point in the history
Wa3 openapi integration
  • Loading branch information
alyahmedaly authored Feb 27, 2021
2 parents 5af0091 + 0d35f21 commit 493b198
Show file tree
Hide file tree
Showing 8 changed files with 697 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
target/
70 changes: 70 additions & 0 deletions service-sdk/10.0.0/migrate-to-open-api/messaging-api/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env groovy

pipeline {
agent any

tools {
maven 'maven'
nodejs 'node'
}

environment {
BACKBASE_REGISTRY = "https://repo.backbase.com/api/npm/npm-backbase/"
PUBLISH_REGISTRY = "https://myregistry.backbase.com/"
RELEASE_BRANCH_PATTERN = /^(master|release\/.*)$/
}

stages {
stage('Build') {
steps {
script {
sh 'mvn clean compile'
dir('target/generated-sources/openapi') {
sh "npm install --@backbase:registry=${BACKBASE_REGISTRY}"
sh "npm run build"
}
}
}
}

stage('Update API') {
when { not { expression { BRANCH_NAME ==~ RELEASE_BRANCH_PATTERN } } }
steps {
script {
dir('typescript-angular-api') {
sh "npm install"
sh "npm run api:extract"
sh "git add ."
gitChanges = sh(returnStatus: true, script: 'git diff --staged --exit-code -- .')
if (gitChanges != 0) {
sh "git commit -m 'Updated typescript API'"
sh "git push origin HEAD:${env.BRANCH_NAME}"
}
}
}
}
}

stage('Test') {
steps {
script {
dir('typescript-angular-api') {
sh "npm install"
sh "npm run api:check"
}
}
}
}

stage('Deploy') {
when { expression { BRANCH_NAME ==~ RELEASE_BRANCH_PATTERN } }
steps {
script {
dir('target/generated-sources/openapi/dist') {
sh "npm publish --registry ${PUBLISH_REGISTRY}"
}
}
}
}
}
}
41 changes: 41 additions & 0 deletions service-sdk/10.0.0/migrate-to-open-api/messaging-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,44 @@ Fill out this file with some information about your OpenAPI spec.

To build this spec, use:
- mvn spring-boot:run

## Frontend Code Generation

### Generate and Build

Code is generated using [openapi-generator](https://openapi-generator.tech/).

```bash
mvn clean compile
cd target/generated-sources/openapi
npm install --@backbase:registry=https://repo.backbase.com/api/npm/npm-backbase/
npm run build
```

### Public API Report

Public API report is created using [api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor).

*Note*: First run the code generation.

```bash
cd typescript-angular-api
npm install
npm run api:check
```

### Publish

After generating the `dist` of the generated sources can be published.

```
cd target/generated-sources/openapi/dist
npm publish
```

## Example Pipeline

The `Jenkinsfile` contains an example pipeline which executes the above steps. It may need to be configured furher to suit your environment. As it is configured it will:
- Generate and build the frontend code
- If not on a release branch, update the public API report
- If on a release branch, verify the public API report and publish the generated package
41 changes: 17 additions & 24 deletions service-sdk/10.0.0/migrate-to-open-api/messaging-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,34 @@
<version>1.0.0-SNAPSHOT</version>
<name>Backbase :: Digital Banking Services :: messaging-api</name>

<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.0</version>
</dependency>

<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
</dependency>
</dependencies>
<properties>
<codegen.npmPackage.name>@backbase/message-http-ang</codegen.npmPackage.name>
<codegen.npmPackage.version>${version}</codegen.npmPackage.version>
<codegen.generateMocks>true</codegen.generateMocks>
<codegen.apiModulePrefix>Message</codegen.apiModulePrefix>
<codegen.angularVersion>10.1.0</codegen.angularVersion>
<codegen.buildDist>dist/libs/transactions-http-ang</codegen.buildDist>
<codegen.serviceSuffix>HttpService</codegen.serviceSuffix>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<groupId>com.backbase.oss</groupId>
<artifactId>boat-maven-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<id>generate-client-api-code</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
<generatorName>typescript-angular</generatorName>
<additionalProperties>ngVersion=${codegen.angularVersion},npmName=${codegen.npmPackage.name},npmVersion=${codegen.npmPackage.version},withMocks=${codegen.generateMocks},apiModulePrefix=${codegen.apiModulePrefix},buildDist=${codegen.buildDist},serviceSuffix=${codegen.serviceSuffix}</additionalProperties>
</configuration>
</execution>
</executions>
<configuration>
<inputSpec>src/main/resources/openapi.yaml</inputSpec>
<output>${project.build.directory}/generated-sources/api</output>
<configOptions>
<apiPackage>message</apiPackage>
<modelPackage>message.model</modelPackage>
</configOptions>
</configuration>
</plugin>
<!--maven-jar-plugin is only including the OpenAPI spec and examples in the built artifact -->
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"projectFolder": "../target/generated-sources/openapi",
"mainEntryPointFilePath": "<projectFolder>/dist/public_api.d.ts",
"bundledPackages": [],
"compiler": {
"tsconfigFilePath": "<projectFolder>/tsconfig.json"
},
"apiReport": {
"enabled": true,
"reportFolder": ".",
"reportTempFolder": "<projectFolder>/temp/"
},
"docModel": {
"enabled": false
},
"dtsRollup": {
"enabled": false
},
"tsdocMetadata": {
"enabled": false
},
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
},
"ae-missing-release-tag": {
"logLevel": "none",
"addToApiReportFile": false
},
"ae-forgotten-export": {
"logLevel": "warning",
"addToApiReportFile": true
},
"ae-incompatible-release-tags": {
"logLevel": "none",
"addToApiReportFile": false
},
"ae-internal-missing-underscore": {
"logLevel": "none",
"addToApiReportFile": false
},
"ae-unresolved-inheritdoc-reference": {
"logLevel": "none",
"addToApiReportFile": false
},
"ae-unresolved-inheritdoc-base": {
"logLevel": "none",
"addToApiReportFile": false
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
},
"tsdoc-unsupported-tag": {
"logLevel": "none"
},
"tsdoc-undefined-tag": {
"logLevel": "none"
},
"tsdoc-param-tag-missing-hyphen": {
"logLevel": "none"
},
"tsdoc-malformed-inline-tag": {
"logLevel": "none"
},
"tsdoc-escape-right-brace": {
"logLevel": "none"
}
}
}
}
Loading

0 comments on commit 493b198

Please sign in to comment.