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

Create action to test generated file matches #1

Merged
merged 2 commits into from
Apr 4, 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
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test
on:
pull_request:
branches:
- "*"
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20.12.0
- name: Install dependencies
run: yarn install
- name: Generate API file
run: yarn generate
- name: Check generated files match
uses: tj-actions/verify-changed-files@v19
with:
files: |
src/Brevo.ts
fail-if-changed: true
fail-message: "Generate API file is different to the committed one. Please run `yarn generate` and commit the changes."
1 change: 0 additions & 1 deletion generate.sh

This file was deleted.

21 changes: 21 additions & 0 deletions generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { generateApi } from "swagger-typescript-api";
import path from "path";

generateApi({
name: "Brevo.ts",
// @ts-ignore
apiClassName: "Brevo",
url: "https://api.brevo.com/v3/swagger_definition.yml",
output: path.resolve(__dirname, "src"),
httpClientType: "axios",
hooks: {
// Fix date example changing to current date on every run
onParseSchema: (schema) => {
if (schema.example && schema.example instanceof Date) {
schema.example = "2024-01-22T09:25:00.000Z";
}
},
},
}).then(() => {
process.exit(0);
});
57 changes: 0 additions & 57 deletions git_push.sh

This file was deleted.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"clean": "rm -Rf node_modules/ *.js",
"build": "tsc"
"build": "tsc",
"generate": "ts-node generate.ts"
},
"author": "Brevo",
"license": "MIT",
"dependencies": {
"axios": "^1.6.8"
},
"devDependencies": {
"@types/node": "^20.12.4",
"swagger-typescript-api": "^13.0.3",
"ts-node": "^10.9.2",
"typescript": "^5.4.3"
}
}
16 changes: 8 additions & 8 deletions src/Brevo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ export interface GetWhatsappCampaignOverview {
campaignStatus: "draft" | "scheduled" | "pending" | "approved" | "running" | "suspended" | "rejected" | "sent";
/**
* UTC date-time on which WhatsApp campaign is scheduled. Should be in YYYY-MM-DDTHH:mm:ss.SSSZ format
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
scheduledAt?: string;
/**
Expand All @@ -970,12 +970,12 @@ export interface GetWhatsappCampaignOverview {
template: WhatsappCampTemplate;
/**
* Creation UTC date-time of the WhatsApp campaign (YYYY-MM-DDTHH:mm:ss.SSSZ)
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
createdAt: string;
/**
* UTC date-time of last modification of the WhatsApp campaign (YYYY-MM-DDTHH:mm:ss.SSSZ)
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
modifiedAt: string;
}
Expand Down Expand Up @@ -1082,12 +1082,12 @@ export interface GetWATemplates {
errorReason?: string;
/**
* Creation UTC date-time of the whatsApp template (YYYY-MM-DDTHH:mm:ss.SSSZ)
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
createdAt: string;
/**
* UTC date-time of last modification of the whatsApp template (YYYY-MM-DDTHH:mm:ss.SSSZ)
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
modifiedAt: string;
}[];
Expand Down Expand Up @@ -1124,7 +1124,7 @@ export interface GetWhatsappCampaigns {
campaignStatus: "draft" | "scheduled" | "pending" | "approved" | "running" | "suspended" | "rejected" | "sent";
/**
* UTC date-time on which WhatsApp campaign is scheduled. Should be in YYYY-MM-DDTHH:mm:ss.SSSZ format
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
scheduledAt: string;
/**
Expand All @@ -1147,12 +1147,12 @@ export interface GetWhatsappCampaigns {
stats?: WhatsappCampStats;
/**
* Creation UTC date-time of the WhatsApp campaign (YYYY-MM-DDTHH:mm:ss.SSSZ)
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
createdAt: string;
/**
* UTC date-time of last modification of the whatsApp template (YYYY-MM-DDTHH:mm:ss.SSSZ)
* @example "2024-04-03T18:18:49.106Z"
* @example "2024-01-22T09:25:00.000Z"
*/
modifiedAt: string;
}[];
Expand Down
16 changes: 3 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"noImplicitAny": false,
"target": "ES6",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"noLib": false,
"declaration": true,
"lib": ["dom", "es6", "es5", "dom.iterable", "scripthost"],
"outDir": "dist",
"typeRoots": ["node_modules/@types"]
},
"exclude": ["dist", "node_modules"]
"skipLibCheck": true
}
}
Loading