Search code examples
typescriptswaggerswagger-codegenapi-eveonline

Typescript and Swagger Codegen. What to include where?


So I've generated some swagger models and api services from the swagger file located at https://esi.tech.ccp.is/latest/swagger.json which gives me a file structure similar to:

Generated File Structure

I've included the following files:

app.module.ts

// Eve ESI Swagger Codegen APIs
import { ApiModule } from '../providers/ESISwagger';
import { HttpClientModule } from '@angular/common/http';

providers: [
    ...
    ApiModule,
    HttpClientModule,
    HTTP, // Ioniic Native HTTP Plugin
    ...
  ]

Let's say I have a page "fleet-management.ts". I am trying to import the API to be able to use the Fleets service the codegen generated. I've tried including the service, the API file and such and I cannot for the life of my figure out how to access it and reference it correctly.

Any help with what files to include and a basic example of using one of the generated functions would be great. It's a little more complicated again by the fact the API also has configuration options which I can't figure out either :(


Solution

  • This is now solved. The ApiModule needed to be an import (not a provider) in the app.module.ts such as the below:

    // Swagger Client Services
    import { ApiModule } from '../providers/esi/index';
    ...
    imports: [
        ...
        ApiModule,
        HttpClientModule,
        ...
      ],
    ...