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

Merge from upstream #8

Merged
merged 8 commits into from
Jan 13, 2022
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
63 changes: 63 additions & 0 deletions .github/workflows/Avantation-Build-Manual-Test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Avantation Package Build Test

on: workflow_dispatch

jobs:
Avantation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm install

- name: Install oclif-dev
run: npm install -g @oclif/dev-cli

- name: Testing
run: npm run test

- name: Package metadata
id: metadata
run: |
set -x
sudo apt-get install jq
export PACKAGE_VERSION=$(cat package.json | jq -r .version)
export PACKAGE_NAME="avantation-v${PACKAGE_VERSION}"
export PACKAGE_LIST="./dist/${PACKAGE_NAME}/*"

echo "::set-output name=package-version::${PACKAGE_VERSION}"
echo "::set-output name=package-name::${PACKAGE_NAME}"
echo "::set-output name=package-dir::${PACKAGE_LIST}"

- name: Package Build
run: |
oclif-dev pack --root avantation

# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# tag_name: tv1.0.0 #${{ github.ref }}
# release_name: Release tv1.0.0 #${{ github.ref }}
# body_path: Hello world #${{ steps.changelog.outputs.path }}
# draft: false

- name: Release package to Github #ref: https://hub.github.com/hub-release.1.html
id: upload-plugin-asset
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -x
assets=()
export DIR="${{ steps.metadata.outputs.package-dir }}"
for asset in $DIR; do
assets+=("-a" "$asset")
done
tag_name="tv1.0.0" #"${GITHUB_REF##*/}"
hub release create "${assets[@]}" -d -m "$tag_name" "v${{ steps.metadata.outputs.package-name }}"
16 changes: 16 additions & 0 deletions .github/workflows/manual_release_npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Manual Release Package to NPM
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/release_github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Create Github Release

on:
push:
tags:
- 'v*.*.*'

jobs:
Avantation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm install

- name: Install oclif-dev
run: npm install -g @oclif/dev-cli

- name: Testing
run: npm run test

- name: Package metadata
id: metadata
run: |
set -x
sudo apt-get install jq
export PACKAGE_VERSION=$(cat package.json | jq -r .version)
export PACKAGE_NAME="avantation-v${PACKAGE_VERSION}"
export PACKAGE_LIST="./dist/${PACKAGE_NAME}/*"

echo "::set-output name=package-version::${PACKAGE_VERSION}"
echo "::set-output name=package-name::${PACKAGE_NAME}"
echo "::set-output name=package-dir::${PACKAGE_LIST}"

- name: Package Build
run: oclif-dev pack

- name: Release package to Github #ref: https://hub.github.com/hub-release.1.html
id: upload-plugin-asset
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -x
assets=()
export DIR="${{ steps.metadata.outputs.package-dir }}"
for asset in $DIR; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}" #${{ github.ref }}
hub release create "${assets[@]}" -m "$tag_name" "${{ steps.metadata.outputs.package-name }}"
18 changes: 18 additions & 0 deletions .github/workflows/release_npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Package to NPM
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</a>
</p>

avantation is tool the for generate OpenAPI3.0 from HTTP Archive format(HAR).
avantation is a tool to generate an OpenAPI 3.0 specification from HTTP Archive format(HAR).

avantation is written and maintained by Anbarasan K (anbuksv@gmail.com).

Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "avantation",
"description": "Build OpenAPI3.0 specification from HAR",
"version": "2.0.4",
"version": "2.0.5",
"author": "Anbarasan K <anbuksv@gmail.com> (https://www.avantation.in)",
"bin": {
"avantation": "./bin/run"
Expand Down Expand Up @@ -45,7 +45,7 @@
"REST",
"REST API'S",
"API",
"OpenAPI Sepecification",
"OpenAPI Specification",
"OAS",
"Swagger",
"HAR",
Expand Down
8 changes: 6 additions & 2 deletions src/apis/avantation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const YAML: any = require('json2yaml');

export class AvantationAPI implements Avantation.InputConfig {
har: HAR.Final;
title: string;
template: OAS.Template;
host: string;
basePath: string;
Expand All @@ -31,6 +32,7 @@ export class AvantationAPI implements Avantation.InputConfig {

constructor(input: Avantation.InputConfig, oclif: any) {
this.har = input.har;
this.title = input.title;
this.host = input.host;
this.basePath = input.basePath;
this.pathParamRegex = input.pathParamRegex;
Expand All @@ -49,7 +51,7 @@ export class AvantationAPI implements Avantation.InputConfig {

private async run() {
this.har.log.entries.forEach(this.buildEntry.bind(this));
this.onBuildComplete(this.template);
this.onBuildComplete();
}

logSuccess(head: string): void {
Expand Down Expand Up @@ -381,7 +383,7 @@ export class AvantationAPI implements Avantation.InputConfig {
];
}

onBuildComplete(openapi: OAS.Template): void {
onBuildComplete(): void {
if (!this.template.tags) this.template.tags = [];

if (!this.disableTag)
Expand All @@ -392,6 +394,8 @@ export class AvantationAPI implements Avantation.InputConfig {
}

let that = this;
this.template.info.title = that.title;

this.template.servers.forEach(function (server: OAS.ServerObject) {
server.url = server.url.replace('{host}', that.host);
if (server.variables && server.variables.basePath && typeof server.variables.basePath == 'object') {
Expand Down
2 changes: 1 addition & 1 deletion src/apis/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as HAR from '../interfaces/har';
import * as GenerateSchema from './json.js';
import GenerateSchema from './json.js';
export namespace Util {
export function generateSchema(input: any): any {
let schema = GenerateSchema(input)
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Avantation extends Command {
description: 'Write output result in JSON format.'
}),
'disable-tag': flags.boolean({
description: 'Diable end points grouping based on route path in HAR'
description: 'Disable end points grouping based on route path in HAR'
}),
'security-headers': flags.string({
char: 's',
Expand All @@ -73,7 +73,7 @@ class Avantation extends Command {
}),
'http-snippet': flags.boolean({
description:
"Generate HTTP smaple code snippet for request and appedn it as 'x-code-sample' to OpenAPI path object.",
"Generate HTTP sample code snippet for request and append it as 'x-code-sample' to OpenAPI path object.",
default: false
})
};
Expand Down Expand Up @@ -102,6 +102,7 @@ class Avantation extends Command {
: "";
var input: AvantationInterface.InputConfig = {
har: har,
title: "Avantation REST Template",
host: host,
basePath: flags['base-path'] || '',
template: template,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/avantation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface build {

export interface InputConfig {
har: HAR.Final;
title: string;
host: string;
basePath: string;
template: OAS.Template;
Expand Down
2 changes: 1 addition & 1 deletion src/templates/avantation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let defaultTemplate: any = {
openapi: '3.0.0',
info: {
version: '1.0',
title: 'Avantation REST Template',
title: '{title}',
description: 'TODO: Add Description'
},
servers: [
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"module": "commonjs",
"outDir": "lib",
Expand Down