Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init sdk #2

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-optional-chaining",
[
"@babel/plugin-proposal-pipeline-operator",
{
"proposal": "minimal"
}
],
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-do-expressions",
"@babel/plugin-proposal-function-bind"
]
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
60 changes: 60 additions & 0 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: builder

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
sdk:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate SDK
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: javascript
openapi-url: https://raw.githubusercontent.com/bavix/gripmock-openapi/master/api.yaml
command-args: -o . --package-name gripmock-sdk-js -c config.yaml

- name: "Check if build has changed"
if: success()
id: has-changes
run: |
echo "stdout<<EOF" >> $GITHUB_OUTPUT
echo "$(git diff --stat)" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: "git add --all"
run: git add --all

- name: Import GPG key
if: ${{ steps.has-changes.outputs.stdout }}
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_BOT }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
fingerprint: ${{ secrets.GPG_FINGERPRINT }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: Github bot
git_committer_email: [email protected]

- name: "Commit files"
if: ${{ steps.has-changes.outputs.stdout }}
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
git commit -S -m "sdk generated" -a
- name: "Push changes"
if: ${{ steps.has-changes.outputs.stdout }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: git push -u origin HEAD
14 changes: 14 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: update changelog

on:
release:
types: [released]

permissions: {}

jobs:
changelog:
permissions:
contents: write
secrets: inherit
uses: bavix/.github/.github/workflows/[email protected]
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish package to GitHub Packages
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v3
with:
node-version: '21.x'
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file
scope: '@bavix'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*
23 changes: 23 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
43 changes: 43 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.babelrc
.gitignore
.openapi-generator-ignore
.travis.yml
README.md
docs/AddStub200Response.md
docs/AddStubRequest.md
docs/HealthcheckApi.md
docs/MessageOK.md
docs/SearchRequest.md
docs/SearchResponse.md
docs/Stub.md
docs/StubHeaders.md
docs/StubInput.md
docs/StubOutput.md
docs/StubsApi.md
git_push.sh
mocha.opts
package.json
src/ApiClient.js
src/api/HealthcheckApi.js
src/api/StubsApi.js
src/index.js
src/model/AddStub200Response.js
src/model/AddStubRequest.js
src/model/MessageOK.js
src/model/SearchRequest.js
src/model/SearchResponse.js
src/model/Stub.js
src/model/StubHeaders.js
src/model/StubInput.js
src/model/StubOutput.js
test/api/HealthcheckApi.spec.js
test/api/StubsApi.spec.js
test/model/AddStub200Response.spec.js
test/model/AddStubRequest.spec.js
test/model/MessageOK.spec.js
test/model/SearchRequest.spec.js
test/model/SearchResponse.spec.js
test/model/Stub.spec.js
test/model/StubHeaders.spec.js
test/model/StubInput.spec.js
test/model/StubOutput.spec.js
1 change: 1 addition & 0 deletions .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.0-SNAPSHOT
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
cache: npm
node_js:
- "6"
- "6.1"
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gen-client:
# https://github.com/OpenAPITools/openapi-generator
openapi-generator generate -i https://raw.githubusercontent.com/bavix/gripmock-openapi/master/api.yaml -g javascript -o ./generated/
150 changes: 150 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# gripmock-sdk-js

GripmockSdkJs - JavaScript client for gripmock-sdk-js
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 2.4.0
- Package version: 2.4.0
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen

## Installation

### For [Node.js](https://nodejs.org/)

#### npm

To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).

Then install it via:

```shell
npm install gripmock-sdk-js --save
```

Finally, you need to build the module:

```shell
npm run build
```

##### Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:

```shell
npm install
```

Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:

```shell
npm link
```

To use the link you just defined in your project, switch to the directory you want to use your gripmock-sdk-js from, and run:

```shell
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
```

Finally, you need to build the module:

```shell
npm run build
```

#### git

If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID
then install it via:

```shell
npm install GIT_USER_ID/GIT_REPO_ID --save
```

### For browser

The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
the above steps with Node.js and installing browserify with `npm install -g browserify`,
perform the following (assuming *main.js* is your entry file):

```shell
browserify main.js > bundle.js
```

Then include *bundle.js* in the HTML pages.

### Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error:
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
the following section to your webpack config:

```javascript
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
```

## Getting Started

Please follow the [installation](#installation) instruction and execute the following JS code:

```javascript
var GripmockSdkJs = require('gripmock-sdk-js');


var api = new GripmockSdkJs.HealthcheckApi()
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.liveness(callback);

```

## Documentation for API Endpoints

All URIs are relative to *https://raw.githubusercontent.com/api*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*GripmockSdkJs.HealthcheckApi* | [**liveness**](docs/HealthcheckApi.md#liveness) | **GET** /health/liveness | Liveness check
*GripmockSdkJs.HealthcheckApi* | [**readiness**](docs/HealthcheckApi.md#readiness) | **GET** /health/readiness | Readiness check
*GripmockSdkJs.StubsApi* | [**addStub**](docs/StubsApi.md#addStub) | **POST** /stubs | Add a new stub to the store
*GripmockSdkJs.StubsApi* | [**batchStubsDelete**](docs/StubsApi.md#batchStubsDelete) | **POST** /stubs/batchDelete | Deletes a pack by IDs
*GripmockSdkJs.StubsApi* | [**deleteStubByID**](docs/StubsApi.md#deleteStubByID) | **DELETE** /stubs/{uuid} | Deletes stub by ID
*GripmockSdkJs.StubsApi* | [**listStubs**](docs/StubsApi.md#listStubs) | **GET** /stubs | Getting a list of stubs
*GripmockSdkJs.StubsApi* | [**listUnusedStubs**](docs/StubsApi.md#listUnusedStubs) | **GET** /stubs/unused | Getting a list of unused stubs
*GripmockSdkJs.StubsApi* | [**listUsedStubs**](docs/StubsApi.md#listUsedStubs) | **GET** /stubs/used | Getting a list of used stubs
*GripmockSdkJs.StubsApi* | [**purgeStubs**](docs/StubsApi.md#purgeStubs) | **DELETE** /stubs | Remove all stubs
*GripmockSdkJs.StubsApi* | [**searchStubs**](docs/StubsApi.md#searchStubs) | **POST** /stubs/search | Stub storage search


## Documentation for Models

- [GripmockSdkJs.AddStub200Response](docs/AddStub200Response.md)
- [GripmockSdkJs.AddStubRequest](docs/AddStubRequest.md)
- [GripmockSdkJs.MessageOK](docs/MessageOK.md)
- [GripmockSdkJs.SearchRequest](docs/SearchRequest.md)
- [GripmockSdkJs.SearchResponse](docs/SearchResponse.md)
- [GripmockSdkJs.Stub](docs/Stub.md)
- [GripmockSdkJs.StubHeaders](docs/StubHeaders.md)
- [GripmockSdkJs.StubInput](docs/StubInput.md)
- [GripmockSdkJs.StubOutput](docs/StubOutput.md)


## Documentation for Authorization

Endpoints do not require authorization.

4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
additionalProperties:
projectName: gripmock-sdk-js
projectVersion: 2.4.0
licenseName: MIT
Loading