Skip to content

Conversation

@willm
Copy link
Contributor

@willm willm commented Mar 21, 2016

Skeleton typescript typings. Apart from Basket and Release, which has been done manually with proper types, these were generated from the script below:

'use strict';
var schema = require('./assets/7digital-api-schema');

const resources = schema.resources;

for (var className in resources) {
    let methods = resources[className].actions.map((x) => x.methodName);
    const fnDefs = methods.map((m) => {
        return `\t${m}: (
        params: any,
        callback: (
            err:Error,
            response:any
        ) => void
    ) => void;`
    });
    console.log(`export class ${className} {
${fnDefs.join('\n')}
}\n`);
}

@raoulmillais
Copy link
Contributor

Nice :) This could be useful for typescript ppl. For it to be really useful, I think it's necessary to cover the whole API schema with proper types (as you have for basket and release) before merging and releasing.

@willm
Copy link
Contributor Author

willm commented Mar 22, 2016

agreed, I'm also wondering/looking at if I can put in some tests/checks to make sure it doesn't get out of date.

There's an issue that the new usage types parameter actually affects the schema. Seeing as this is the future of the api, maybe we should think about forcing the usageTypes=download parameter by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants