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.

Smart naming when generating services

See original GitHub issue

Hi,

I’m consuming an API that has this path: /api/v1/management/organizations

This generates a OrganizationsService, which is fine, but there is no mention of management, or even v1 anywhere.

If we assume that the service name should be whatever comes after /api We could get V1ManagementOrganizationsService

It’s horrible, but it works.

Another option is to generate those services in folders following the path, so:

/core
/models
/services
   /v1
       /management
            OrganizationsService.ts

v1 and management don’t have anything so we could create just a placeholder object to have the reference to the children:

export class V1{
   public static Management: Management = Management
}

export class Management{
   public static Organizations: OrganizationsService = OrganizationsService 
}

//we have this already
export class OrganizationsService {
}

Following the previous snippet, I could now just V1.Management.Organizations.getAll()

I’m doing this currently by hand, and would be nice to automate it 😃

Cheers

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
yordiscommented, Nov 6, 2020

x-service-name: string[] is what we used in the past.

0reactions
natepappenhagencommented, Nov 20, 2020

@ferdikoomen Came here to say I would really like this feature. I’ve built some custom-generators using the openAPI library and it was super easy to just extend the SpringCodeGen and write some custom normalization logic for my method names. It’s a game changer for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

10 Do's And Don'ts For Smart Naming
9. Do embrace emotion. Reason alone does not a great name make. Instead of being totally left-brain, you should let some intuition guide...
Read more >
A Smarter Approach to Naming Conventions - Adverity
A powerful aspect of the Smart Naming Conventions feature is its ability to spot missing values based on neighbouring ones. It then politely ......
Read more >
The Power of Smart Document Names - The Grizzly Labs
Smart Document Names are a powerful feature of Genius Scan+ (the pro ... To create a smart document name, you can combine various...
Read more >
Configure the Name Generator Service - Intergraph Smart 3D
Search for and open Services. The Services window displays. Right-click the Intergraph Smart 3D Name Generator service, and then select Properties.
Read more >
268 Creative Business Name Ideas (Curated, Not Generated!)
Ditch the business name generators and use this list of over 200 creative, catchy, ... Catchy business name ideas; Smart business name ideas ......
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