Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#342 - introduce standalone flag #345

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mumenthalers
Copy link

@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
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 }),
  ]
})

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
2 participants