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

Docs omit Servers property #52

Closed
bradygaster opened this issue Feb 20, 2021 · 4 comments · Fixed by #55
Closed

Docs omit Servers property #52

bradygaster opened this issue Feb 20, 2021 · 4 comments · Fixed by #55
Assignees
Labels
bug Something isn't working resolved Request has been resolved v0.5.0

Comments

@bradygaster
Copy link

I followed the docs - which are MUCH-improved and getting exciting - and ran into one issue. When I follow the tutorial explicitly the OpenApiConfigurationOptions class I created lacks the Servers property, so I get a compilation error.

image

I can add this manually, but I think this approach to hard-coding it is sub-optimal and I'd prefer us not recommend someone hard-code localhost into their C# code.

public List<OpenApiServer> Servers 
{ 
    get
    {
      return ( new OpenApiServer[] { new OpenApiServer { Url = "https://localhost:7071" }}).ToList();
    }
    set => throw new NotImplementedException(); 
}

Is there a way that the Functions runtime can provide this? Something we could do to mitigate the customer's need to have to do this OR provide some sort of guidance that wouldn't require hard-coding?

@justinyoo
Copy link
Contributor

Oh, the localhost one should be automatically added, without having to explicitly implement the interface. I thought it would do it. Let me check.

@justinyoo justinyoo self-assigned this Feb 21, 2021
@justinyoo justinyoo added bug Something isn't working v0.5.0 working labels Feb 21, 2021
@bradygaster
Copy link
Author

BTW I was able to resolve this both locally in development and post-production without making any code tweaks. Just making sure folks see that this is possible.

public List<OpenApiServer> Servers 
    { 
      get
      {
        return ( new OpenApiServer[] { new OpenApiServer { Url = 
          //"https://localhost:7071"
          Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME")
        }}).ToList();
      }
      set => throw new NotImplementedException(); 
    }

Curious what folks would prefer?

  1. We just do this in something like a DefaultOpenApiConfigurationOptions implementation of IOpenApiConfigurationOptions and ship it in the binding.
  2. We don't add a DefaultOpenApiConfigurationOptions of IOpenApiConfigurationOptions, force folks to implement it, and add this approach to the tutorial and/or the template [that may or may not exist or be planned]. :)

@justinyoo
Copy link
Contributor

I prefer the option 1.

@justinyoo justinyoo linked a pull request Feb 22, 2021 that will close this issue
@justinyoo justinyoo added resolved Request has been resolved and removed working labels Feb 22, 2021
@justinyoo
Copy link
Contributor

This has been released to NuGet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Request has been resolved v0.5.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants