jonnii / speakeasy Goto Github PK
View Code? Open in Web Editor NEWMaking http easy... hopefully.
License: Apache License 2.0
Making http easy... hopefully.
License: Apache License 2.0
https://msdn.microsoft.com/en-us/library/system.net.http.headers.httpresponseheaders(v=vs.118).aspx
To enable access to other headers such as Location
Something like this:
client.Get("search", new { perPage = 30 });
Should be transformed into:
search?per_page=30
Hi @jonnii , it would be good to support dictionary like query string parameters, something like this:
var fields = new Dictionary<object, object>()
{
{ "foo": "foo-values" },
{ "bar": "bar-values" }
}
httpClient.Get("authors", new { fields })
// -> translates to "GET ...authors?fields[foo]=foo-values&fields[bar]=bar-values"
The ApiController
accepts such query string parameters natively ([FromQuery] Dictionary<string, string> fields
), it would be great if speakeasy would support creating the parameters from a dictionary also
return httpClient.PostAsync(new { arguments }, "admin/tasks/:taskName", new { taskName })
.On(HttpStatusCode.NotAcceptable, handler => throw new InvalidOperationException(handler.AsString()))
.On(HttpStatusCode.BadRequest, handler => throw new InvalidOperationException(handler.AsString()))
.OnOk()
.AsWrapped<T>();
This helps tremendously when debugging.
Use simple json.
Enums
Steps to reproduce:
public DateTime CreatedAt { get; set; }
public Product()
{
CreatedAt = DateTime.Now;
}
Tests that try to deserialize this will fail
pass naming convention down into default serializer?
private Header Update(Model model)
{
var response = Client.Put(model, "models/:id", new { model.Id });
response.On(HttpStatusCode.NotFound, () => { throw new Exception("Not found"); });
response.On(HttpStatusCode.BadRequest, (List<ValidationError> errors) =>
{
throw new ValidationException(errors);
});
return response.On(HttpStatusCode.OK).As<Header>();
}
When using On(Code, Action) don't throw exceptions if the status code does not match the expected status code.
This can happen if creating a client with the default settings... this should be clearer.
Under the covers, HttpClient uses a new protocol, and in our testing, using Windows authentication will usually result in an Unauthorized
error. See https://docs.microsoft.com/en-US/dotnet/core/run-time-config/networking
In .Net 3.x, you could work around this by forcing HttpClient to use the old stack, using:
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
However in .Net 5.0 this setting is no longer available. Instead, you'd need to use the https://www.nuget.org/packages/System.Net.Http.WinHttpHandler package and use that handler. Trouble is, this is a Windows-only thing, and adding this as a dependency in SpeakEasy will make it non-cross platform.
I thought of adding a DefaultClientHandler
property to HttpClientSettings
. Trouble is that all the IAuthenticator
implementations use HttpClientSettings
in their signatures, and we'd have change it to be HttpMessageHandler
, which is a significant breaking change. Furthermore, the WindowsAuthenticator
wouldn't work with that implementation either, given that the handler can either be a HttpClientHandler
or a WinHttpHandler
, both of which use different properties to set the credentials.
Conundrum.
It should be possible to register a default handler, for example BadRequest which can unwrap and throw an exception.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.