question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

clientBaseClass option is not importing/copying the base class to the output file

See original GitHub issue

Hey guys,

I tried to wire the clientBaseClass option, because I need to use the transformOptions method to add custom HTTP Headers for authentication purposes. I’m generating a TypeScript client. I think my nswag.json has everything required set up:

...
"useTransformOptionsMethod": true,
"clientBaseClass": "ServiceBase",
"extensionCode": "api-client.extensions.ts",
"output": "au-api-client.ts"
...

I set it up, based on this. My problem is that an import statement is missing for the ServiceBase class in the generated file, so the generated client cannot be used at all:

import { inject } from 'aurelia-framework';
import { HttpClient, RequestInit } from 'aurelia-fetch-client';

import * as moment from 'moment';

@inject(String, HttpClient)
export class ApplicationService extends ServiceBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
...

Here it seems to add the base class to the generated file, but for me it does not.

Version info: Generated using the NSwag toolchain v11.6.1.0 (NJsonSchema v9.5.0.0)

Any ideas how to fix it? Thank you.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:7
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
HJoostcommented, Feb 5, 2018

I encountered the same problem. It seems that it has to do with windows/unix file endings. On my windows machine this doesn’t work:

export class Lvsapibaseclient {…}

But this ugly one get’s generated in the right way:

export class Lvsapibaseclient /*\r */{…}

1reaction
RicoSutercommented, Sep 12, 2017

Somehow the extension code loader does not find your class and does not load your class:

https://github.com/RSuter/NJsonSchema/blob/master/src/NJsonSchema.CodeGeneration.TypeScript/TypeScriptExtensionCode.cs#L29

Do you see a problem here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to copy data from base class to derived class fastly?
1 Answer 1 ... There is no general way to do this, as the layout of the data in the base and derived...
Read more >
When amsart is used as a base class of another ...
After glancing at amsclass source documentation and a bit of experimenting, i observed that simply using \documentclass[fleqn]{myamsart} in my ...
Read more >
The Designer could not be shown for this file because ...
I have a project produced in Visual Studio 2017. I have just downloaded Visual Studio 2022 and tried to open the project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found