Skip to content

DateTime formatted as round-trip#170

Merged
sergey-tihon merged 2 commits intofsprojects:masterfrom
xperiandri:date-time-round-trip
Dec 13, 2020
Merged

DateTime formatted as round-trip#170
sergey-tihon merged 2 commits intofsprojects:masterfrom
xperiandri:date-time-round-trip

Conversation

@xperiandri
Copy link
Copy Markdown
Contributor

@sergey-tihon could you have a look?
I guess I have not fixed all the stuff.

Here is a decompile of the code generated for my Swagger document:

public Task<OilChange.Day[]> GetAvailableSlotsSince(DateTimeOffset date, int daysSinceSpecified)
{
	object value = date;
	object value1 = daysSinceSpecified;
	HttpRequestMessage httpRequestMessage = RuntimeHelpers.createHttpRequest("Get", Regex.Replace(Regex.Replace("/availableSlotsFrom/{date}/{daysSinceSpecified}", "{date}", !Operators.IsNull<object>(value) ? value.ToString() : null), "{daysSinceSpecified}", !Operators.IsNull<object>(value1) ? value1.ToString() : null), (IEnumerable<Tuple<string, string>>)FSharpList<Tuple<string, string>>.Empty);
	Lambda04e97ca0-3699-4b90-b7f9-0844e380b2a9lambda04e97ca0 = new Lambda04e97ca0-3699-4b90-b7f9-0844e380b2a9();
	lambda04e97ca0.mapping = new Lambda190c6e31-8c0e-4702-b562-c7c718c42cb7();
	FSharpFunc<Tuple<string, string>, bool> fSharpFunc = Operators.op_ComposeRight<Tuple<string, string>, bool, bool>(Operators.op_ComposeRight<Tuple<string, string>, string, bool>(new Lambda0735ecc1-5d8c-4c3e-921d-4a9d97082e47(), new Lambda5dc26cb3-9d4c-4d0c-9570-696b81cf8582()), new Lambda3199b202-bdf9-478a-a043-daeec3cc61c7());
	Lambda3cca6c0f-b188-4424-8c54-d39fda84a8c9lambda3cca6c0f = new Lambda3cca6c0f-b188-4424-8c54-d39fda84a8c9();
	lambda3cca6c0f.predicate = fSharpFunc;
	string item2 = ((FSharpFunc<IEnumerable<string>, string>)new Lambda7a9f89b4-5756-48bc-9af5-34f6c73eb850()).Invoke(((FSharpFunc<IEnumerable<Tuple<string, string>>, IEnumerable<string>>)lambda04e97ca0).Invoke(((FSharpFunc<FSharpList<Tuple<string, string>>, IEnumerable<Tuple<string, string>>>)lambda3cca6c0f).Invoke(FSharpList<Tuple<string, string>>.Empty)));
	RuntimeHelpers.fillHeaders(httpRequestMessage, (IEnumerable<Tuple<string, string>>)FSharpList<Tuple<string, string>>.Cons(new Tuple<string, string>("Cookie", item2), 1 == null ? FSharpList<Tuple<string, string>>.Empty : FSharpList<Tuple<string, string>>.Cons(new Tuple<string, string>("Content-Type", "application/json"), FSharpList<Tuple<string, string>>.Empty)));
	Lambda823c0166-5ddf-41ec-9261-e5fe584cee7flambda823c0166 = new Lambda823c0166-5ddf-41ec-9261-e5fe584cee7f();
	lambda823c0166.@this = this;
	lambda823c0166.x = ((ProvidedApiClientBase)this).CallAsync(httpRequestMessage, new string[0], new string[0]);
	return (Task<OilChange.Day[]>)RuntimeHelpers.taskCast((Type)Type.GetTypeFromHandle(OilChange.Day[]), FSharpAsync.StartAsTask<object>(((FSharpFunc<FSharpAsyncBuilder, FSharpAsync<object>>)lambda823c0166).Invoke(ExtraTopLevelOperators.DefaultAsyncBuilder), FSharpOption<TaskCreationOptions>.None, FSharpOption<CancellationToken>.None));
}

Here ToString() must be called as ToString("O")
Regex.Replace("/availableSlotsFrom/{date}/{daysSinceSpecified}", "{date}", !Operators.IsNull(value) ? value.ToString() : null)

Comment thread global.json Outdated
Comment thread paket.dependencies Outdated
Comment thread paket.dependencies
@xperiandri xperiandri force-pushed the date-time-round-trip branch 2 times, most recently from 43c7664 to 012a47f Compare December 11, 2020 22:54
@xperiandri
Copy link
Copy Markdown
Contributor Author

Comments fixed but look like my changes have not fixed the URL creation

@sergey-tihon
Copy link
Copy Markdown
Member

How do you know that it does not fix the url creation?

I think that we can add one more endpoint here - https://github.com/fsprojects/SwaggerProvider/blob/master/tests/Swashbuckle.WebApi.Server/Controllers/ReturnControllers.fs#L37 that received date as url parameter and deserialize of from url and then add test somewhere here https://github.com/fsprojects/SwaggerProvider/blob/master/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.ReturnControllers.Tests.fs#L95 to call this endpoint.

with the test your change will be protected from future changes

@xperiandri
Copy link
Copy Markdown
Contributor Author

How do you know that it does not fix the url creation?

I look at decompile

@xperiandri xperiandri marked this pull request as ready for review December 13, 2020 20:19
@sergey-tihon sergey-tihon merged commit 427825b into fsprojects:master Dec 13, 2020
@sergey-tihon
Copy link
Copy Markdown
Member

Thank you @xperiandri
Released as v0.11.0

@xperiandri
Copy link
Copy Markdown
Contributor Author

Cool! Thank you very much!

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.

2 participants