Skip to content

Conversation

mumenthalers
Copy link
Contributor

@mumenthalers mumenthalers commented Jan 1, 2025

closes #342

changes:

  • standalone option added
  • prevent module being generated when standalone is set
  • generate and export provideApiConfiguration (accepting value or factory)

@mumenthalers mumenthalers changed the title #342 introduce standalone flag #342 - introduce standalone flag Jan 1, 2025
@scurk1415
Copy link

scurk1415 commented Jan 8, 2025

Will this work in case of multiple schemas? I for example have 2 BE services (schemas) and I have to generate 2 different configs, which generate 2 different modules.

Example: ChatApiModule and UserApiModule

Which i then import:

importProvidersFrom([
    UserApiModule.forRoot({ rootUrl: USER_SERVICE_ENDPOINT_PREFIX }),
    ChatApiModule.forRoot({ rootUrl: CHAT_SERVICE_ENDPOINT_PREFIX }),
]),

Will your solution work in this use case?

@mumenthalers
Copy link
Contributor Author

yes - it works the same way as module (which defaults to ApiModule).
You need to provide a custom name for the configurationClass

{
  "$schema": "../node_modules/ng-openapi-gen/ng-openapi-gen-schema.json",
  "input": "user-api.yaml",
  "module": false,
  "configuration": "UserApiConfiguration"
}
{
  "$schema": "../node_modules/ng-openapi-gen/ng-openapi-gen-schema.json",
  "input": "chat-api.yaml",
  "module": false,
  "configuration": "ChatApiConfiguration"
}

then you can use it like

bootstrapApplication(AppComponent, {
  providers: [
    provideUserApiConfiguration({ rootUrl: USER_SERVICE_ENDPOINT_PREFIX }),
    provideChatApiConfiguration({ rootUrl: CHAT_SERVICE_ENDPOINT_PREFIX }),
  ]
})

@colsen1991
Copy link

@luisfpg, is there anything I can do to help expedite this PR? We're very much looking forward to seeing this option being implemented.

@michael-pisman
Copy link

Any updates?

@ivebeenlinuxed
Copy link

I've tested this. Looks great!

@bioc-druzgami
Copy link

@mumenthalers I see there are some conflicts to resolve now. I hope this can be merged soon. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce Standalone Flag

6 participants