GithubHelp home page GithubHelp logo

Comments (3)

bigopon avatar bigopon commented on May 27, 2024

@arnederuwe This is expected behavior. When a constructor is registered to be injected, it will be instantiated and value of new String() call is an empty string.

For NSwag, what you need to do is to register the service client in your main.ts:

export function configure(aurelia: Aurelia) {
  aurelia
    .use
    .instance(
      MyGeneratedServiceClass,
      new MyGeneratedServiceClass('http://path/to/my/base/url', aurelia.container.get(HttpClient))
    );
}

from dependency-injection.

arnederuwe avatar arnederuwe commented on May 27, 2024

Thanks for clarifying, I am doing something similar as you are describing to circumvent it:

export function configure(config: FrameworkConfiguration) {
	config.container.registerSingleton(
		ImageClient,
		() => new ImageClient(null, config.container.get(HttpClient))
	);
	config.container.registerSingleton(
		ContainerClient,
		() => new ContainerClient(null, config.container.get(HttpClient))
	);
	config.container.registerSingleton(
		CustomerClient,
		() => new CustomerClient(null, config.container.get(HttpClient))
	);
	config.container.registerSingleton(
		TenantInfoTokenClient,
		() => new TenantInfoTokenClient(null, config.container.get(HttpClient))
	);
}

Problem is I'm having a lot of clients, and this code isn't really DRY :) that's why I wanted to use nswag's url resolver function, but that only get's triggered when an undefined is passed to the client. I'll file an issue with NSwag, as there really is no clean way to utilize their resolver function because of this.

from dependency-injection.

bigopon avatar bigopon commented on May 27, 2024

@arnederuwe Please link the issue in this, thanks! 😄

from dependency-injection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.