Skip to content

Commit

Permalink
Aktiver build pipeline generering av typescript klient.
Browse files Browse the repository at this point in the history
  • Loading branch information
josstn committed Nov 11, 2024
1 parent f17092d commit 6d295a8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 122 deletions.
16 changes: 0 additions & 16 deletions .github/actions/generate-openapi/README.md

This file was deleted.

72 changes: 0 additions & 72 deletions .github/actions/generate-openapi/action.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/actions/generate-typescript-client/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ runs:
id: typescript-generate
uses: navikt/openapi-ts-clientmaker@v1
with:
openapi-spec-file: web/src/main/resources/openapi-ts-client/k9-sak.openapi.json
openapi-spec-file: web/src/main/resources/openapi-ts-client/ung-sak.openapi.json
package-json-file: web/src/main/resources/openapi-ts-client/package.json
package-json-version: "${{ env.PACKAGE_JSON_VERSION }}"
out-dir: "${{ steps.set-output.outputs.resultDir }}"
client-name: K9SakClient
client-name: UngSakClient
env:
PACKAGE_JSON_VERSION: "${{ inputs.openapiVersion }}.${{ inputs.patchVersion }}"
51 changes: 26 additions & 25 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,32 @@ jobs:
secrets: inherit


# build-typescript-client:
# name: Build typescript client
# runs-on: ubuntu-latest
# needs: build-app
# permissions:
# contents: write
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/actions/generate-openapi
# id: generate-openapi
# with:
# readerToken: ${{ secrets.READER_TOKEN }}
# githubToken: ${{ secrets.GITHUB_TOKEN }}
# - uses: ./.github/actions/generate-typescript-client
# id: generate-typescript
# with:
# openapiVersion: ${{ steps.generate-openapi.outputs.openapiVersion }}
# patchVersion: ${{ needs.build-app.outputs.build-version }}
# # Upload generated typescript package, so it can be downloaded and published by later job
# - uses: actions/upload-artifact@v4
# id: upload-typescript
# with:
# name: k9-sak-typescript-client-src
# path: "${{ steps.generate-typescript.outputs.resultDir }}"
# if-no-files-found: error
build-typescript-client:
name: Build typescript client
runs-on: ubuntu-latest
needs: build-app
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: navikt/sif-gha-workflows/.github/actions/maven/generate-openapi
id: generate-openapi
with:
readerToken: ${{ secrets.READER_TOKEN }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
openapiFileName: ung-sak.openapi.json
- uses: ./.github/actions/generate-typescript-client
id: generate-typescript
with:
openapiVersion: ${{ steps.generate-openapi.outputs.openapiVersion }}
patchVersion: ${{ needs.build-app.outputs.build-version }}
# Upload generated typescript package, so it can be downloaded and published by later job
- uses: actions/upload-artifact@v4
id: upload-typescript
with:
name: ung-sak-typescript-client-src
path: "${{ steps.generate-typescript.outputs.resultDir }}"
if-no-files-found: error

verdikjede-tester:
name: Verdikjedetester
Expand Down
14 changes: 7 additions & 7 deletions web/src/main/resources/openapi-ts-client/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
openapi-ts-client
=================

This directory contains the generated **k9-sak.openapi.json** specification file and other files used as input to define
This directory contains the generated **ung-sak.openapi.json** specification file and other files used as input to define
a generated openapi typescript client.

The k9-sak.openapi.json file is generated from the java source in this project, and represents a specification of the
The ung-sak.openapi.json file is generated from the java source in this project, and represents a specification of the
rest api the web server provides.

It is used to generate and publish a typescript/javascript client library npm package for communicating with the web server.

The k9-sak.openapi.json file is automatically generated during the build pipeline. Changes to the generated result is
The ung-sak.openapi.json file is automatically generated during the build pipeline. Changes to the generated result is
automatically committed to git in the build pipeline. One should never edit the file manually.

This is done so that the build pipeline can detect if there are changes in the api spec since last deployment, and only
Expand All @@ -24,7 +24,7 @@ client is built in the GitHub pipeline. See the GitHub workflow definition for m
## Use of published package

The generated package is published as a **GitHub npm package
[@navikt/k9-sak-typescript-client](https://github.com/navikt/k9-sak/pkgs/npm/k9-sak-typescript-client)**.
[@navikt/ung-sak-typescript-client](https://github.com/navikt/ung-sak/pkgs/npm/ung-sak-typescript-client)**.
It can be used like this:

### installation
Expand All @@ -33,11 +33,11 @@ Install the package as usual from GitHub package registry. More info about that

### Code example
```typescript
import { K9SakClient } from "@navikt/k9-sak-typescript-client";
import { UngSakClient } from "@navikt/ung-sak-typescript-client";

const organisasjonsnr = 111222333; // input
const k9sak = new K9SakClient();
const mottakerinfo = await k9sak.brev.getBrevMottakerinfoEreg({organisasjonsnr})
const ungSak = new UngSakClient();
const mottakerinfo = await ungSak.brev.getBrevMottakerinfoEreg({organisasjonsnr})

console.debug(`mottaker navn: ${mottakerinfo?.navn}`)
```

0 comments on commit 6d295a8

Please sign in to comment.