Server API stubs provider #81
Replies: 11 comments
-
Interested in thoughts here. Should this be a type provider based on OWIN or ASP.NET Core types? Or should this potentially be a code generator tool or something else entirely? |
Beta Was this translation helpful? Give feedback.
-
As I've been rebasing my prototype on top of the
Thoughts? I'm going to continue rebasing with this idea in mind and hopefully make more progress towards actually generating the function signature that accepts the generated request type and returns the generated response type. |
Beta Was this translation helpful? Give feedback.
-
I agree with the implementation based on I think that we should do the following (in big) type IContract = // provided interface with all infered signatures
begin end // one method per operation from the schema
type ProvidedClient(host, params) =
// virtual methods for serialization, deserialization, HTTP call interceptor and etc
// virtual Call method `HttpRequestMessage -> Task<HttpResponseMessage>`
interface IContract with
// method for each operation, build HttpRequestMessage for each operation and call `Call` method
type DefaultServer() =
// for those who want to implement only some part of the contract (for example for testing)
interface IContract with
// default implementation for each method, throw NotImplementedException
type OwinHost(impl: IContract) =
// Methods to plug into OWIN pipeline
// Routing generated based on the schema, that identifies operation, extract data from HttpRequestMessage and call the appropriate method from `impl` So when we want to implement server API based on the generated schema, we implement the Thoughts? |
Beta Was this translation helpful? Give feedback.
-
@sergey-tihon I like that! I think that's a bit simpler, too, than generating a type with methods accepting implementation callbacks. Is there already an interface generated for
Another question: you mention in your comment one operation per interface, right? What about grouping those by controller prefix? By default, it would generate separate contracts per operation, but if Lastly, once I make some progress on this, would you like me to re-target my PR to this repository? Sounds like there is interest in pulling it in eventually. |
Beta Was this translation helpful? Give feedback.
-
Found the answer: http://blog.mavnn.co.uk/modelling-inheritance-with-inheritance/ |
Beta Was this translation helpful? Give feedback.
-
No, but I think that it is the good thing to do.
Yes, plus maybe some other configuration parameters
Yes, names in my sample are conceptual, so if you can do better names - I am fine with it (
My bad, I meant one operation = one method.
Agree here as well. It is even implemented in type OwinHost(impl1: IContract1, impl2: IContract2, ... implN: IContractN) = when you do not want to provide impl, you use
Sure, just want to ask you to do this! |
Beta Was this translation helpful? Give feedback.
-
I was trying to find how to apply an interface implementation in a type provider and mostly found problems without solutions. Is it supported? Per @mavnn’s posts, it seems neither abstract classes nor interfaces can be successfully added to generated types, but perhaps that has changed. Any pointers? |
Beta Was this translation helpful? Give feedback.
-
As to your comments, I’m fully on board and excited to make it happen! |
Beta Was this translation helpful? Give feedback.
-
Last question: should we generate all this from one type provider? You could then create instances of client or host depending on use case, and you would get a shared set of interfaces, for whatever that is worth. |
Beta Was this translation helpful? Give feedback.
-
I hope so, but I am not sure... We need some experiments, maybe abstract class will work instead of interface (if we will have no luck with interface) What I know:
I think that one TP is OK, I do not really see reason to separate |
Beta Was this translation helpful? Give feedback.
-
Once I get interface generation working, I will submit a PR here. For now, I think fsprojects/FSharp.TypeProviders.SDK#211 is blocking progress. That, or my TP-fu is worse than useless, and I should sign up for an FSSF mentor to help me. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/panesofglass/SwaggerProvider/pull/1/files
Beta Was this translation helpful? Give feedback.
All reactions