Initial commit

master
Jonas Franz 5 years ago
commit b9873c2224
  1. 3
      .gitignore
  2. 23
      .swagger-codegen-ignore
  3. 1
      .swagger-codegen/VERSION
  4. 54
      README.md
  5. 514
      api.ts
  6. 21
      package.json
  7. 17
      tsconfig.json
  8. 101
      tslint.json
  9. 9
      typings.json

3
.gitignore vendored

@ -0,0 +1,3 @@
wwwroot/*.js
node_modules
typings

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# 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 Swagger Codgen 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

@ -0,0 +1,54 @@
# TypeScript-Fetch
This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
Environment
* Node.js
* Webpack
* Browserify
Language level
* ES5 - you must have a Promises/A+ library installed
* ES6
Module system
* CommonJS
* ES6 module system
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
### Installation ###
`swagger-codegen` does not generate JavaScript directly. The generated Node module comes with `package.json` that bundles `typescript` and `typings` so it can self-compile during `prepublish` stage. The should be run automatically during `npm install` or `npm publish`.
CAVEAT: Due to [privilege implications](https://docs.npmjs.com/misc/scripts#user), `npm` would skip all scripts if the user is `root`. You would need to manually run it with `npm run prepublish` or run `npm install --unsafe-perm`.
#### NPM ####
You may publish the module to NPM. In this case, you would be able to install the module as any other NPM module. It maybe useful to use [scoped packages](https://docs.npmjs.com/misc/scope).
You can also use `npm link` to link the module. However, this would not modify `package.json` of the installing project, as such you would need to relink every time you deploy that project.
You can also directly install the module using `npm install file_path`. If you do `npm install file_path --save`, NPM will save relative path to `package.json`. In this case, `npm install` and `npm shrinkwrap` may misbehave. You would need to manually edit `package.json` and replace it with absolute path.
Regardless of which method you deployed your NPM module, the ES6 module syntaxes are as follows:
```
import * as localName from 'npmName';
import {operationId} from 'npmName';
```
The CommonJS syntax is as follows:
```
import localName = require('npmName');
```
#### Direct copy/symlink ####
You may also simply copy or symlink the generated module into a directory under your project. The syntax of this is as follows:
With ES6 module syntax, the following syntaxes are supported:
```
import * as localName from './symlinkDir';
import {operationId} from './symlinkDir';
```
The CommonJS syntax is as follows:
```
import localName = require('./symlinkDir')';
```

514
api.ts

@ -0,0 +1,514 @@
/**
* Organizer
* Dies ist eine API, die es ermöglicht Daten zu Stunden-, Vertretungs-, oder Klausurplänen zu erhalten.
*
* OpenAPI spec version: 1.0.0
* Contact: info@jonasfranz.software
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import * as querystring from "querystring";
import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign";
interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }
const BASE_PATH = "http://api.organizer.martin-luther.schule/v1".replace(/\/+$/, "");
export interface FetchArgs {
url: string;
options: any;
}
export class BaseAPI {
basePath: string;
fetch: FetchAPI;
constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) {
this.basePath = basePath;
this.fetch = fetch;
}
};
export interface Exam {
"id"?: number;
"date"?: Date;
/**
* The period of the day where the exam starts
*/
"startPeriod"?: number;
/**
* The period of the day where the exam ends
*/
"endPeriod"?: number;
"lesson"?: Lesson;
}
export interface Lesson {
"weekday"?: number;
/**
* The period of the day where the lesson is
*/
"period"?: number;
/**
* Class or Course
*/
"course"?: string;
"subject"?: Subject;
"teacher"?: Teacher;
/**
* An additional information like 'Every 14 days only'
*/
"additionalInformation"?: string;
"room"?: string;
}
export interface ReplacementLesson {
"id"?: number;
"date"?: Date;
"lesson"?: Lesson;
"replacementLesson"?: Lesson;
}
export interface Subject {
/**
* The abbreviation of the subject like LB for sports.
*/
"abbreviation"?: string;
"name"?: string;
}
export interface Teacher {
/**
* An unique string that is mostly the abbreviation of the teacher's name
*/
"identifier"?: string;
/**
* The family name of the teacher
*/
"name"?: string;
}
/**
* ExaminationSchedulingApi - fetch parameter creator
*/
export const ExaminationSchedulingApiFetchParamCreator = {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any): FetchArgs {
// verify required parameter "course" is set
if (params["course"] == null) {
throw new Error("Missing required parameter course when calling getExams");
}
const baseUrl = `/course/{course}/exams`
.replace(`{${"course"}}`, `${ params["course"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
};
/**
* ExaminationSchedulingApi - functional programming interface
*/
export const ExaminationSchedulingApiFp = {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<Exam>> {
const fetchArgs = ExaminationSchedulingApiFetchParamCreator.getExams(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
};
/**
* ExaminationSchedulingApi - object-oriented interface
*/
export class ExaminationSchedulingApi extends BaseAPI {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any) {
return ExaminationSchedulingApiFp.getExams(params, options)(this.fetch, this.basePath);
}
};
/**
* ExaminationSchedulingApi - factory interface
*/
export const ExaminationSchedulingApiFactory = function (fetch?: FetchAPI, basePath?: string) {
return {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any) {
return ExaminationSchedulingApiFp.getExams(params, options)(fetch, basePath);
},
};
};
/**
* ReplacementLessonsApi - fetch parameter creator
*/
export const ReplacementLessonsApiFetchParamCreator = {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any): FetchArgs {
const baseUrl = `/replacement/findAll`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any): FetchArgs {
// verify required parameter "date" is set
if (params["date"] == null) {
throw new Error("Missing required parameter date when calling findReplacementLessonsByDate");
}
const baseUrl = `/replacement/findByDate`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
"date": params["date"],
});
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any): FetchArgs {
// verify required parameter "id" is set
if (params["id"] == null) {
throw new Error("Missing required parameter id when calling getReplacement");
}
const baseUrl = `/replacement/{id}`
.replace(`{${"id"}}`, `${ params["id"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any): FetchArgs {
// verify required parameter "course" is set
if (params["course"] == null) {
throw new Error("Missing required parameter course when calling getReplacementByCourse");
}
const baseUrl = `/course/{course}/replacements`
.replace(`{${"course"}}`, `${ params["course"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
};
/**
* ReplacementLessonsApi - functional programming interface
*/
export const ReplacementLessonsApiFp = {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<ReplacementLesson>> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.findReplacementLessons(options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<ReplacementLesson>> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.findReplacementLessonsByDate(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<ReplacementLesson> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.getReplacement(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<ReplacementLesson>> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.getReplacementByCourse(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
};
/**
* ReplacementLessonsApi - object-oriented interface
*/
export class ReplacementLessonsApi extends BaseAPI {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any) {
return ReplacementLessonsApiFp.findReplacementLessons(options)(this.fetch, this.basePath);
}
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any) {
return ReplacementLessonsApiFp.findReplacementLessonsByDate(params, options)(this.fetch, this.basePath);
}
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any) {
return ReplacementLessonsApiFp.getReplacement(params, options)(this.fetch, this.basePath);
}
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any) {
return ReplacementLessonsApiFp.getReplacementByCourse(params, options)(this.fetch, this.basePath);
}
};
/**
* ReplacementLessonsApi - factory interface
*/
export const ReplacementLessonsApiFactory = function (fetch?: FetchAPI, basePath?: string) {
return {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any) {
return ReplacementLessonsApiFp.findReplacementLessons(options)(fetch, basePath);
},
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any) {
return ReplacementLessonsApiFp.findReplacementLessonsByDate(params, options)(fetch, basePath);
},
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any) {
return ReplacementLessonsApiFp.getReplacement(params, options)(fetch, basePath);
},
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any) {
return ReplacementLessonsApiFp.getReplacementByCourse(params, options)(fetch, basePath);
},
};
};
/**
* TimetableApi - fetch parameter creator
*/
export const TimetableApiFetchParamCreator = {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any): FetchArgs {
// verify required parameter "course" is set
if (params["course"] == null) {
throw new Error("Missing required parameter course when calling getTimetable");
}
const baseUrl = `/course/{course}/timetable`
.replace(`{${"course"}}`, `${ params["course"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
};
/**
* TimetableApi - functional programming interface
*/
export const TimetableApiFp = {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<Lesson>> {
const fetchArgs = TimetableApiFetchParamCreator.getTimetable(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
};
/**
* TimetableApi - object-oriented interface
*/
export class TimetableApi extends BaseAPI {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any) {
return TimetableApiFp.getTimetable(params, options)(this.fetch, this.basePath);
}
};
/**
* TimetableApi - factory interface
*/
export const TimetableApiFactory = function (fetch?: FetchAPI, basePath?: string) {
return {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any) {
return TimetableApiFp.getTimetable(params, options)(fetch, basePath);
},
};
};

@ -0,0 +1,21 @@
{
"name": "typescript-fetch-api",
"version": "0.0.0",
"license": "Unlicense",
"main": "./dist/api.js",
"browser": "./dist/api.js",
"typings": "./dist/api.d.ts",
"dependencies": {
"core-js": "^2.4.0",
"isomorphic-fetch": "^2.2.1"
},
"scripts" : {
"prepublish" : "typings install && tsc",
"test": "tslint api.ts"
},
"devDependencies": {
"tslint": "^3.15.1",
"typescript": "^1.8.10",
"typings": "^1.0.4"
}
}

@ -0,0 +1,17 @@
{
"compilerOptions": {
"declaration": true,
"target": "es5",
"module": "commonjs",
"noImplicitAny": true,
"outDir": "dist",
"rootDir": "."
},
"exclude": [
"dist",
"node_modules",
"typings/browser",
"typings/main",
"typings/main.d.ts"
]
}

@ -0,0 +1,101 @@
{
"jsRules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"double"
],
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
},
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"double"
],
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}

@ -0,0 +1,9 @@
{
"version": false,
"dependencies": {},
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"node": "registry:dt/node#4.0.0+20160423143914",
"isomorphic-fetch": "registry:dt/isomorphic-fetch#0.0.0+20160505171433"
}
}
Loading…
Cancel
Save