Skip to content

Fails on petstore.json service generation #4

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

Open
johndpope opened this issue Sep 27, 2019 · 1 comment
Open

Fails on petstore.json service generation #4

johndpope opened this issue Sep 27, 2019 · 1 comment

Comments

@johndpope
Copy link

johndpope commented Sep 27, 2019

Using this cannonical json file
https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/petstore.json

The code generation fails

I suspect because the base service specification is mandatory - it's probably my own fault -
but I need some sample base service so that this code generation succeeds.

./generate.sh
yarn run v1.17.3
$ openapi-typescript-client-api-generator -c petstore.json -sb /client/services -s /client/api/services -m /client/api/models -sm /server/modules/api/models
InStage client api generator
Loading config file...
Config file with version 2.0 found.
Running converter...
Converted.
Augmenting config with server models...
Loaded 0 server models.
Added 0 server models to the configuration.
Config file loaded.
Loading api info...
Done.
Loading models...
Loaded 3 models.
Generating model files...
Generated 3 model files.
Loading request bodies...
Loaded 0 request bodies.
Generating request body files...
Generated 0 request body files.
(node:40147) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
at servicesLoader (/Users/admin/Documents/8secondz-workspace/8secondz-axios/node_modules/@progresso/openapi-typescript-client-api-generator/loaders/servicesLoader.js:5:30)
at generate (/Users/admin/Documents/8secondz-workspace/8secondz-axios/node_modules/@progresso/openapi-typescript-client-api-generator/index.js:48:22)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:40147) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:40147) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 0.22s.

N.B. there are some models spat out successfully.

/**
 * Swagger Petstore 1.0.0 (OpenAPI: 3.0.0)
 * 
 *
 * NOTE: This class is auto generated by openapi-typescript-client-api-generator.
 * Do not edit the file manually.
 */

export class Pet {
    public id: number;

    public name: string;

    public tag: string;

    /**
     * Creates a Pet.
     *
     * @param {number} id
     * @param {string} name
     * @param {string} tag
     */
    constructor(id: number, name: string, tag: string) {
        this.id = id;
        this.name = name;
        this.tag = tag;
    }
}
@johndpope
Copy link
Author

I did some digging and re-crafted the sample json awesome-api.json

some things that are particular to point out -

this line
"tags" : [ { "name" : "users" } ,{ "name" : "Account" } ], // needed to specify "Account" here to spit out corresponding service

eg.
"paths": {
"/api/Accounts/createAccount": {
"post": {
"tags": [
"Account" // will now spit out account service
],

My expectation though would be to just trawl through the paths and create the corresponding files.

Screen Shot 2019-10-02 at 3 02 54 pm

Screen Shot 2019-10-02 at 3 01 44 pm

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

No branches or pull requests

1 participant