Removal of the codegen

This commit is contained in:
Eric Schultz 2020-04-22 17:22:36 -05:00
parent 89a0a7ffbc
commit abbfae739c
40 changed files with 671 additions and 593 deletions

3
.gitignore vendored
View file

@ -48,9 +48,6 @@ config/environments/*.local.yml
#local bins we use for builds
.bin
#generated typescript APIs from Grape
javascripts/api
# thing we want to keep in public
!public/*.html
!public/maintenance.html

View file

@ -10,8 +10,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
# this endpoint only creates donor users
def create
params[:user][:referer] = session[:referer_id]
user = User.register_donor!(params[:user])
clean_params[:user][:referer] = session[:referer_id]
user = User.register_donor!(clean_params[:user])
if user.save
sign_in user
render json: user
@ -51,4 +51,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
render json: { errors: errs }, status: :unprocessable_entity
end
end
private
def clean_params
params.permit(:user => [:name, :email, :password_confirmation, :password])
end
end

View file

@ -0,0 +1,5 @@
const pageInfo = {
apiDomain: '<%= Settings.api_domain.url %>'
}
module.exports = pageInfo;

View file

@ -7,8 +7,6 @@ COPY script/build/debian/node.sh myapp/script/build/debian/node.sh
RUN myapp/script/build/debian/node.sh
COPY script/build/debian/postgres.sh myapp/script/build/debian/postgres.sh
RUN myapp/script/build/debian/postgres.sh
COPY script/build/debian/java.sh myapp/script/build/debian/java.sh
RUN myapp/script/build/debian/java.sh
COPY gems /myapp/gems/
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile

View file

@ -7,8 +7,6 @@ COPY script/build/debian/node.sh myapp/script/build/debian/node.sh
RUN myapp/script/build/debian/node.sh
COPY script/build/debian/postgres.sh myapp/script/build/debian/postgres.sh
RUN myapp/script/build/debian/postgres.sh
COPY script/build/debian/java.sh myapp/script/build/debian/java.sh
RUN myapp/script/build/debian/java.sh
COPY gems /myapp/gems/
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile

View file

@ -0,0 +1,197 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 $ from 'jquery';
import * as models from '../model/models';
import { Configuration } from '../configuration';
const page_info = require('../../../app/javascript/page_info.js.erb')
/* tslint:disable:no-unused-variable member-ordering */
export class NonprofitsApi {
protected basePath = `${page_info.apiDomain}/api`;
public defaultHeaders: Array<string> = [];
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
public configuration: Configuration = new Configuration();
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
if (basePath) {
this.basePath = basePath;
}
if (configuration) {
this.configuration = configuration;
}
if (defaultExtraJQueryAjaxSettings) {
this.defaultExtraJQueryAjaxSettings = defaultExtraJQueryAjaxSettings;
}
}
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
for (let key in objB) {
if (objB.hasOwnProperty(key)) {
objA[key] = objB[key];
}
}
return objA;
}
/**
* Return a nonprofit.
* @summary Return a nonprofit.
* @param id Status id.
*/
public getNonprofitId(id: number, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<models.Nonprofit > {
let localVarPath = this.basePath + '/nonprofit/{id}'.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
let queryParameters: any = {};
let headerParams: any = {};
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getNonprofitId.');
}
localVarPath = localVarPath + "?" + $.param(queryParameters);
// to determine the Content-Type header
let consumes: string[] = [
];
// to determine the Accept header
let produces: string[] = [
'application/json'
];
let requestOptions: JQueryAjaxSettings = {
url: localVarPath,
type: 'GET',
headers: headerParams,
processData: false
};
if (headerParams['Content-Type']) {
requestOptions.contentType = headerParams['Content-Type'];
}
if (extraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, extraJQueryAjaxSettings);
}
if (this.defaultExtraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings);
}
let dfd = $.Deferred();
$.ajax(requestOptions).then(
(data: models.Nonprofit, textStatus: string, jqXHR: JQueryXHR) =>
dfd.resolve(jqXHR, data),
(xhr: JQueryXHR, textStatus: string, errorThrown: string) => {
if(false){}
else if (xhr.status == 200 && 200 >= 400)
{
dfd.reject(new models.NonprofitException(<models.Nonprofit>xhr.responseJSON))
}
else
{
dfd.reject(errorThrown)
}
}
);
return dfd.promise();
}
/**
* Register a nonprofit
* @summary Register a nonprofit
* @param Nonprofit
*/
public postNonprofit(Nonprofit: models.PostNonprofit, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<models.Nonprofit > {
let localVarPath = this.basePath + '/nonprofits';
let queryParameters: any = {};
let headerParams: any = {};
// verify required parameter 'Nonprofit' is not null or undefined
if (Nonprofit === null || Nonprofit === undefined) {
throw new Error('Required parameter Nonprofit was null or undefined when calling postNonprofit.');
}
localVarPath = localVarPath + "?" + $.param(queryParameters);
// to determine the Content-Type header
let consumes: string[] = [
'application/json'
];
// to determine the Accept header
let produces: string[] = [
'application/json'
];
headerParams['Content-Type'] = 'application/json';
let requestOptions: JQueryAjaxSettings = {
url: localVarPath,
type: 'POST',
headers: headerParams,
processData: false
};
requestOptions.data = JSON.stringify(Nonprofit);
if (headerParams['Content-Type']) {
requestOptions.contentType = headerParams['Content-Type'];
}
if (extraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, extraJQueryAjaxSettings);
}
if (this.defaultExtraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings);
}
let dfd = $.Deferred();
$.ajax(requestOptions).then(
(data: models.Nonprofit, textStatus: string, jqXHR: JQueryXHR) =>
dfd.resolve(jqXHR, data),
(xhr: JQueryXHR, textStatus: string, errorThrown: string) => {
if(false){}
else if (xhr.status == 201 && 201 >= 400)
{
dfd.reject(new models.NonprofitException(<models.Nonprofit>xhr.responseJSON))
}
else if (xhr.status == 400 && 400 >= 400)
{
dfd.reject(new models.ValidationErrorsException(<models.ValidationErrors>xhr.responseJSON))
}
else
{
dfd.reject(errorThrown)
}
}
);
return dfd.promise();
}
}

View file

@ -0,0 +1,123 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 $ from 'jquery';
import * as models from '../model/models';
import { Configuration } from '../configuration';
const page_info = require('../../../app/javascript/page_info.js.erb')
/* tslint:disable:no-unused-variable member-ordering */
export class UsersApi {
protected basePath = `${page_info.apiDomain}`;
public defaultHeaders: Array<string> = [];
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
public configuration: Configuration = new Configuration();
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
if (basePath) {
this.basePath = basePath;
}
if (configuration) {
this.configuration = configuration;
}
if (defaultExtraJQueryAjaxSettings) {
this.defaultExtraJQueryAjaxSettings = defaultExtraJQueryAjaxSettings;
}
}
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
for (let key in objB) {
if (objB.hasOwnProperty(key)) {
objA[key] = objB[key];
}
}
return objA;
}
/**
* Register a nonprofit
* @summary Register a nonprofit
* @param Nonprofit
*/
public postUser(User: models.PostUser, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<models.Nonprofit > {
let localVarPath = this.basePath + '/users';
let queryParameters: any = {};
let headerParams: any = {};
// verify required parameter 'Nonprofit' is not null or undefined
if (User === null || User === undefined) {
throw new Error('Required parameter Nonprofit was null or undefined when calling postNonprofit.');
}
localVarPath = localVarPath + "?" + $.param(queryParameters);
// to determine the Content-Type header
let consumes: string[] = [
'application/json'
];
// to determine the Accept header
let produces: string[] = [
'application/json'
];
headerParams['Content-Type'] = 'application/json';
let requestOptions: JQueryAjaxSettings = {
url: localVarPath,
type: 'POST',
headers: headerParams,
processData: false
};
requestOptions.data = JSON.stringify(User);
if (headerParams['Content-Type']) {
requestOptions.contentType = headerParams['Content-Type'];
}
if (extraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, extraJQueryAjaxSettings);
}
if (this.defaultExtraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings);
}
let dfd = $.Deferred();
$.ajax(requestOptions).then(
(data: any, textStatus: string, jqXHR: JQueryXHR) =>
dfd.resolve(jqXHR, data),
(xhr: JQueryXHR, textStatus: string, errorThrown: string) => {
if (xhr.status == 422)
{
dfd.reject(new models.ValidationErrorsException(<models.ValidationErrors>xhr.responseJSON))
}
else
{
dfd.reject(errorThrown)
}
}
);
return dfd.promise();
}
}

View file

@ -0,0 +1,5 @@
export * from './NonprofitsApi';
export * from './UsersApi';
import { NonprofitsApi } from './NonprofitsApi';
import { UsersApi } from './UsersApi';
export const APIS = [NonprofitsApi, UsersApi];

3
javascripts/api/index.ts Normal file
View file

@ -0,0 +1,3 @@
export * from './api/api';
export * from './model/models';
export * from './configuration';

View file

@ -0,0 +1,36 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
/**
* Return a nonprofit.
*/
export interface Nonprofit {
id?: string;
}
export class NonprofitException implements Error{
constructor(obj:Nonprofit, message?:string){
this.item = obj;
}
message: string;
stack: string;
name: string;
item: Nonprofit;
}

View file

@ -0,0 +1,36 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
/**
* Register a nonprofit
*/
export interface PostNonprofit extends models.PostNonprofitNonprofit {
}
export class PostNonprofitException implements Error{
constructor(obj:PostNonprofit, message?:string){
this.item = obj;
this.item = obj;
}
message: string;
stack: string;
name: string;
item: PostNonprofit;
}

View file

@ -0,0 +1,72 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
export interface PostNonprofitNonprofit {
/**
* Organization Name
*/
name: string;
/**
* Organization website URL
*/
website?: string;
/**
* Organization Address ZIP Code
*/
zip_code: string;
/**
* Organization Address State Code
*/
state_code: string;
/**
* Organization Address City
*/
city: string;
/**
* Organization email (public)
*/
email?: string;
/**
* Organization phone (public)
*/
phone?: string;
}
export class PostNonprofitNonprofitException implements Error{
constructor(obj:PostNonprofitNonprofit, message?:string){
this.item = obj;
this.item = obj;
this.item = obj;
this.item = obj;
this.item = obj;
this.item = obj;
this.item = obj;
}
message: string;
stack: string;
name: string;
item: PostNonprofitNonprofit;
}

View file

@ -0,0 +1,54 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
export interface PostNonprofitUser {
/**
* Full name
*/
name: string;
/**
* Username
*/
email: string;
/**
* Password
*/
password: string;
/**
* Password confirmation
*/
password_confirmation: string;
}
export class PostNonprofitUserException implements Error{
constructor(obj:PostNonprofitUser, message?:string){
this.item = obj;
this.item = obj;
this.item = obj;
this.item = obj;
}
message: string;
stack: string;
name: string;
item: PostNonprofitUser;
}

View file

@ -0,0 +1,24 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
/**
* Register a nonprofit
*/
export interface PostUser {
user?: models.PostNonprofitUser;
}

View file

@ -0,0 +1,42 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
export interface ValidationError {
/**
* Params where the following had an error.
*/
params?: Array<string>;
/**
* The validation messages for the params
*/
messages?: Array<string>;
}
export class ValidationErrorException implements Error{
constructor(obj:ValidationError, message?:string){
this.item = obj;
this.item = obj;
}
message: string;
stack: string;
name: string;
item: ValidationError;
}

View file

@ -0,0 +1,39 @@
/**
* API title
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 0.0.1
*
*
* 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 models from './models';
/**
* Register a nonprofit
*/
export interface ValidationErrors {
/**
* errors
*/
errors?: Array<models.ValidationError>;
}
export class ValidationErrorsException implements Error{
constructor(obj:ValidationErrors, message?:string){
this.item = obj;
}
message: string;
stack: string;
name: string;
item: ValidationErrors;
}

View file

@ -0,0 +1,7 @@
export * from './Nonprofit';
export * from './PostNonprofit';
export * from './PostNonprofitNonprofit';
export * from './PostNonprofitUser';
export * from './PostUser';
export * from './ValidationError';
export * from './ValidationErrors';

View file

@ -12,9 +12,12 @@ import {WizardState, WizardTabPanelState} from "../common/wizard/wizard_state";
import UserInfoPanel, * as UserInfo from "./UserInfoPanel";
import {
Nonprofit,
NonprofitApi,
NonprofitsApi,
PostNonprofit,
ValidationErrorsException
ValidationErrorsException,
UsersApi,
PostUser,
PostNonprofitUser
} from "../../../api";
import {initializationDefinition} from "../../../../types/mobx-react-form";
@ -36,16 +39,22 @@ const setTourCookies = (nonprofit:Nonprofit) => {
document.cookie = `tour_supporters=${nonprofit.id};path=/`
document.cookie = `tour_subscribers=${nonprofit.id};path=/`
}
/** this is just here to allow compilation. */
interface TemporaryHackyInterface {
nonprofit: PostNonprofit
user: PostNonprofitUser
}
export class RegistrationPageForm extends HoudiniForm {
converter: StaticFormToErrorAndBackConverter<PostNonprofit>
converter: StaticFormToErrorAndBackConverter<TemporaryHackyInterface>
constructor(definition: initializationDefinition, options?: any) {
super(definition, options)
this.converter = new StaticFormToErrorAndBackConverter<PostNonprofit>(this.inputToForm)
this.converter = new StaticFormToErrorAndBackConverter<TemporaryHackyInterface>(this.inputToForm)
}
nonprofitApi: NonprofitApi
nonprofitApi: NonprofitsApi
usersApi: UsersApi
signinApi: WebUserSignInOut
options() {
@ -78,9 +87,11 @@ export class RegistrationPageForm extends HoudiniForm {
try {
let r = await this.nonprofitApi.postNonprofit(input)
const userMessage = {user: input.user}
let user = await this.usersApi.postUser(userMessage)
this.signinApi.postLogin({email: input.user.email, password: input.user.password})
let r = await this.nonprofitApi.postNonprofit(input.nonprofit)
setTourCookies(r)
await this.signinApi.postLogin({email: input.user.email, password: input.user.password})
window.location.href = `/nonprofits/${r.id}/dashboard`
}
@ -155,8 +166,9 @@ export class InnerRegistrationWizard extends React.Component<RegistrationWizardP
componentWillMount()
{
runInAction(() => {
this.form.nonprofitApi = this.props.ApiManager.get(NonprofitApi)
this.form.nonprofitApi = this.props.ApiManager.get(NonprofitsApi)
this.form.signinApi = this.props.ApiManager.get(WebUserSignInOut)
this.form.usersApi = this.props.ApiManager.get(UsersApi)
})
}

View file

@ -1,45 +0,0 @@
## {{npmName}}@{{npmVersion}}
This generator creates TypeScript/JavaScript client that utilizes [jQuery](https://jquery.com/). 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))
### Building
To build an compile the typescript sources to javascript use:
```
npm install
npm run build
```
### Publishing
First build the package then run ```npm publish```
### Consuming
navigate to the folder of your consuming project and run one of the following commands.
_published:_
```
npm install {{npmName}}@{{npmVersion}} --save
```
_unPublished (not recommended):_
```
npm install PATH_TO_GENERATED_PACKAGE --save

View file

@ -1,260 +0,0 @@
{{>licenseInfo}}
{{#jqueryAlreadyImported}}
declare var $ : any;
{{/jqueryAlreadyImported}}
{{^jqueryAlreadyImported}}
import * as $ from 'jquery';
{{/jqueryAlreadyImported}}
import * as models from '../model/models';
import { COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
/* tslint:disable:no-unused-variable member-ordering */
{{#operations}}
{{#description}}
/**
* {{&description}}
*/
{{/description}}
export class {{classname}} {
protected basePath = '{{{basePath}}}';
public defaultHeaders: Array<string> = [];
public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
public configuration: Configuration = new Configuration();
constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
if (basePath) {
this.basePath = basePath;
}
if (configuration) {
this.configuration = configuration;
}
if (defaultExtraJQueryAjaxSettings) {
this.defaultExtraJQueryAjaxSettings = defaultExtraJQueryAjaxSettings;
}
}
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
for (let key in objB) {
if (objB.hasOwnProperty(key)) {
objA[key] = objB[key];
}
}
return objA;
}
{{#operation}}
/**
* {{&notes}}
{{#summary}}
* @summary {{&summary}}
{{/summary}}
{{#allParams}}
* @param {{paramName}} {{description}}
{{/allParams}}
*/
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}} > {
let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}.replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}};
let queryParameters: any = {};
let headerParams: any = {};
{{#hasFormParams}}
let formParams = new FormData();
let reqHasFile = false;
{{/hasFormParams}}
{{#allParams}}
{{#required}}
// verify required parameter '{{paramName}}' is not null or undefined
if ({{paramName}} === null || {{paramName}} === undefined) {
throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
}
{{/required}}
{{/allParams}}
{{#queryParams}}
{{#isListContainer}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element: any) => {
queryParameters['{{baseName}}'].push(element);
});
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
queryParameters['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== null && {{paramName}} !== undefined) {
{{#isDateTime}}
queryParameters['{{baseName}}'] = {{paramName}}.toISOString();
{{/isDateTime}}
{{^isDateTime}}
{{#isDate}}
queryParameters['{{baseName}}'] = {{paramName}}.toISOString();
{{/isDate}}
{{^isDate}}
queryParameters['{{baseName}}'] = <string><any>{{paramName}};
{{/isDate}}
{{/isDateTime}}
}
{{/isListContainer}}
{{/queryParams}}
localVarPath = localVarPath + "?" + $.param(queryParameters);
{{#formParams}}
{{#isFile}}
reqHasFile = true;
formParams.append("{{baseName}}", {{paramName}});
{{/isFile}}
{{^isFile}}
{{#isListContainer}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element: any) => {
formParams.append('{{baseName}}', element);
});
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== null && {{paramName}} !== undefined) {
formParams.append('{{baseName}}', <any>{{paramName}});
}
{{/isListContainer}}
{{/isFile}}
{{/formParams}}
{{#headerParams}}
{{#isListContainer}}
if ({{paramName}}) {
headerParams['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);
}
{{/isListContainer}}
{{^isListContainer}}
headerParams['{{baseName}}'] = String({{paramName}});
{{/isListContainer}}
{{/headerParams}}
// to determine the Content-Type header
let consumes: string[] = [
{{#consumes}}
'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}
{{/consumes}}
];
// to determine the Accept header
let produces: string[] = [
{{#produces}}
'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}
{{/produces}}
];
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInHeader}}
if (this.configuration.apiKey) {
headerParams['{{keyParamName}}'] = this.configuration.apiKey;
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (this.configuration.apiKey) {
queryParameters.set('{{keyParamName}}', this.configuration.apiKey);
}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
// http basic authentication required
if (this.configuration.username || this.configuration.password) {
headerParams['Authorization'] = 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password);
}
{{/isBasic}}
{{#isOAuth}}
// oauth required
if (this.configuration.accessToken) {
let accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headerParams['Authorization'] = 'Bearer ' + accessToken;
}
{{/isOAuth}}
{{/authMethods}}
{{#hasFormParams}}
if (!reqHasFile) {
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
}
{{/hasFormParams}}
{{#bodyParam}}
headerParams['Content-Type'] = 'application/json';
{{/bodyParam}}
let requestOptions: JQueryAjaxSettings = {
url: localVarPath,
type: '{{httpMethod}}',
headers: headerParams,
processData: false
};
{{#bodyParam}}
requestOptions.data = JSON.stringify({{paramName}});
{{/bodyParam}}
if (headerParams['Content-Type']) {
requestOptions.contentType = headerParams['Content-Type'];
}
{{#hasFormParams}}
requestOptions.data = formParams;
if (reqHasFile) {
requestOptions.contentType = false;
}
{{/hasFormParams}}
if (extraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, extraJQueryAjaxSettings);
}
if (this.defaultExtraJQueryAjaxSettings) {
requestOptions = (<any>Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings);
}
let dfd = $.Deferred();
$.ajax(requestOptions).then(
(data: {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}, textStatus: string, jqXHR: JQueryXHR) =>
dfd.resolve(jqXHR, data),
(xhr: JQueryXHR, textStatus: string, errorThrown: string) => {
if(false){}
{{#responses}}
else if (xhr.status == {{{code}}} && {{{code}}} >= 400)
{
dfd.reject(new {{dataType}}Exception(<{{dataType}}>xhr.responseJSON))
}
{{/responses}}
else
{
dfd.reject(errorThrown)
}
}
);
return dfd.promise();
}
{{/operation}}
}
{{/operations}}

View file

@ -1,9 +0,0 @@
{{#apiInfo}}
{{#apis}}
{{#operations}}
export * from './{{ classFilename }}';
import { {{ classname }} } from './{{ classFilename }}';
{{/operations}}
{{/apis}}
export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}];
{{/apiInfo}}

View file

@ -1,52 +0,0 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
git_user_id=$1
git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="{{{gitRepoId}}}"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="{{{releaseNote}}}"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View file

@ -1,4 +0,0 @@
export * from './api/api';
export * from './model/models';
export * from './variables';
export * from './configuration';

View file

@ -1,11 +0,0 @@
/**
* {{{appName}}}
* {{{appDescription}}}
*
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
*
* 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.
*/

View file

@ -1,13 +0,0 @@
{{>licenseInfo}}
import * as models from './models';
{{#models}}
{{#model}}
{{#description}}
/**
* {{{description}}}
*/
{{/description}}
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}
{{/model}}
{{/models}}

View file

@ -1,12 +0,0 @@
{{#description}}
/**
* {{{description}}}
*/
{{/description}}
export enum {{classname}} {
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
}

View file

@ -1,45 +0,0 @@
export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{
{{#additionalPropertiesType}}
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
{{/additionalPropertiesType}}
{{#vars}}
{{#description}}
/**
* {{{description}}}
*/
{{/description}}
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
{{/vars}}
}
export class {{classname}}Exception implements Error{
constructor(obj:{{classname}}, message?:string){
{{#vars}}
this.item = obj;
{{/vars}}
}
message: string;
stack: string;
name: string;
item: {{classname}};
}
{{#hasEnums}}
export namespace {{classname}} {
{{#vars}}
{{#isEnum}}
export enum {{enumName}} {
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
}
{{/isEnum}}
{{/vars}}
}{{/hasEnums}}

View file

@ -1,5 +0,0 @@
{{#models}}
{{#model}}
export * from './{{{ classname }}}';
{{/model}}
{{/models}}

View file

@ -1,23 +0,0 @@
{
"name": "{{npmName}}",
"version": "{{npmVersion}}",
"description": "JQuery client for {{npmName}}",
"main": "api.js",
"scripts": {
"build": "tsc"
},
"author": "Swagger Codegen Contributors",
"license": "MIT",
"dependencies": {
"bluebird": "^3.3.5",
"request": "^2.72.0",
"jquery": "^3.1.1"
},
"devDependencies": {
"typescript": "2.2.2",
"typings": "^1.3.0"
}{{#npmRepository}},
"publishConfig":{
"registry":"{{npmRepository}}"
}{{/npmRepository}}
}

View file

@ -1,18 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"noLib": false,
"declaration": true
},
"files": [
"index.ts",
"typings/index.d.ts"
]
}

View file

@ -1,10 +0,0 @@
{
"ambientDependencies": {
"bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"node": "registry:dt/node#4.0.0+20160423143914"
},
"globalDependencies": {
"jquery": "registry:dt/jquery#1.10.0+20170310222111"
}
}

View file

@ -1,7 +0,0 @@
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}

View file

@ -12,25 +12,4 @@ namespace :settings do
require 'pp'
pp Settings.to_hash
end
task generate_json: :environment do
cdn_url = URI(Settings.cdn.url)
cdn_url = cdn_url.to_s
if Settings.button_config&.url
cdn_url = URI(Settings.button_config.url).to_s
end
c = { button: { url: cdn_url, css: "#{cdn_url}/css/donate-button.v2.css" } }
open(File.expand_path('config/settings.json', Rails.root), 'w') do |f|
f.write(c.to_json)
end
end
task combine_translations: 'i18n:js:export' do
js_root = File.expand_path('public/javascripts', Rails.root)
# i18n = File.read(File.join(js_root, 'i18n.js'))
translations = File.read(File.join(js_root, 'translations.js'))
open(File.join(js_root, '_final.js'), 'w') do |f|
f.write("const I18n = require('i18n-js');\n" + translations + "\n window.I18n = I18n")
end
end
end

View file

@ -6,17 +6,10 @@
"url": "https://github.com/houdiniproject/houdini"
},
"scripts": {
"watch": "export HOUDINI_WATCH=1; script/build.sh",
"build": "script/build.sh",
"build-all": "yarn ci && script/compile-assets.sh && yarn build",
"ci-build-all": "script/compile-assets.sh && yarn build",
"test": "rake -v spec && yarn build && yarn jest",
"export-button-config": "bundle exec rake settings:generate_json",
"generate-openapi": "rake oapi:gen",
"get-codegen-cli": "script/download_codegen_cli.sh",
"generate-api-js": "rm -rf javascripts/api && yarn get-codegen-cli && yarn generate-openapi && java -jar .bin/swagger-codegen-cli.jar generate -l 'typescript-jquery' -i tmp/openapi.json -o javascripts/api --config 'swagger.json' -t lib/swagger-typescript-jquery",
"jest": "jest",
"webpack": "webpack"
"jest": "jest"
},
"devDependencies": {
"@babel/preset-env": "^7.7.1",

View file

@ -1,20 +0,0 @@
#!/bin/bash
(
echo $HOUDINI_WATCH
set -e
set -o pipefail
export DATABASE_URL=${BUILD_DATABASE_URL:-postgres://admin:password@db/commitchange_development}
echo $DATABASE_URL
yarn export-i18n && yarn generate-api-js
if [ -n "$HOUDINI_WATCH" ];
then
echo "we're gonna watch!!!"
bin/webpack --watch
else
echo "we're gonna build!!!"
NODE_ENV=production yarn webpack -p
fi
)

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -e
apt-get -yy install default-jre

View file

@ -1,6 +0,0 @@
#!/usr/bin/env bash
if [ ! -e .bin/swagger-codegen-cli.jar ]
then
curl -L https://repo1.maven.org/content/repositories/releases/io/swagger/swagger-codegen-cli/2.3.1/swagger-codegen-cli-2.3.1.jar -o .bin/swagger-codegen-cli.jar --create-dirs
fi

View file

@ -1,3 +0,0 @@
{
"modelPropertyNaming": "original"
}