Skip to content

[openapi-client] Option for emitting a class instead of just functions #25

@Monkatraz

Description

@Monkatraz

Hey, your folk's library is extremely close to what we need for our website we're working on. Straightforward, fairly small emit size, separate types file, etc. However, two features would be really useful:

  1. wrapping all the emitted functions in a class
  2. (minor) option for automatically unwrapping returned data, otherwise throwing an HttpError

The first is useful because it lets you extend the class and modify API calls using super, like so:

class MyAPI extends GeneratedAPI {
  override async authCheckLogin() {
    const result = await super.authCheckLogin()
    // set some global state depending on result, like an `isLoggedIn` observable or something
    return result
   }
}

You could get more detailed and wrap everything in a class but this isn't strictly needed.

The second request is just for convenience, it isn't strictly necessary as it isn't too difficult to do this with some class expression magic, but it would cut down on boilerplate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions