GFlisch / Arc4u.Guidance.Doc

Other
5 stars 1 forks source link

Wrong BaseUrl generated by the Guidance when using 'Add Facade Rest Proxy' in the FrontEnd - Common project #186

Closed SSantiagoDev closed 1 year ago

SSantiagoDev commented 1 year ago

Description of the bug The BaseUrl generated by the Guidance is incorrect when using 'Add Facade Rest Proxy' in the FrontEnd - Common project

To Reproduce

  1. Generate a Facade in the BackEnd
  2. In the FrontEnd, right click on the Common project and then 'Add Facade Rest Proxy'
  3. Select the Facade/SDK you've created
  4. Open the generated *Facade.cs class, line 30
  5. When using that BaseUrl we can see something like this (containing twice the name of the microservice): https://localhost:7236/core/Core/facade/InstructionSet/Hello

Expected behavior The BaseUrl should not contain twice the name of the microservice. Should be like: BaseUrl = $"{tokenSettings.Values["RootServiceUrl"].TrimEnd(new[] { '/' })}/"

Screenshots image

Desktop (please complete the following information):

GFlisch commented 1 year ago

Hi @SSantiagoDev, Thanks for the issue found. The cade has been reworked in the next version of the Guidance coming soon and the problem will be fixed.

The new version is working with settings registered and retrieve based on IOptionsMonitor. The new code will be var tokenSettings = optionsSettings.Get("OAuth2"); if (tokenSettings is not null) { var client = httpClientFactory.CreateClient("OAuth2");

        Proxy = new $(facadename)Client(client)
        {
            BaseUrl = tokenSettings.Values["RootServiceUrl"]
        };
    }

As you see the BaseUrl is not adding anymore the /core/ as mentioned in your example. I have also removed the .TrimEnd because the proxy code generated does this for us: var urlBuilder = new System.Text.StringBuilder(); urlBuilder.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/core/....");