tryAGI / AutoSDK

Automated .NET SDKs for your APIs
https://autosdk.net
Other
15 stars 2 forks source link

Sanitize Property Names #16

Closed Tyler-IN closed 4 months ago

Tyler-IN commented 4 months ago

See https://github.com/HavenDV/OpenApiGenerator/issues/14

This implements the proposal outlined in the issue.

Tyler-IN commented 4 months ago

Working through test cases, adding one for an unofficial generated Twitch OpenAPI document.

        public const string Primary(default) = "primary (default)";

Has additional scenarios such as the above.

Tyler-IN commented 4 months ago

image

Property name is still not sanitized here.

Tyler-IN commented 4 months ago

Found instances of PropertyData.Default with skipping sanitization when assigning name, addressing...

Tyler-IN commented 4 months ago

image

HavenDV commented 4 months ago

UseWordSeparator would turn this into PrimaryDefault. Will it be better?

Tyler-IN commented 4 months ago

I'll extend the init helper to do what FromSchema does

Tyler-IN commented 4 months ago

image

Tyler-IN commented 4 months ago

Now to see what's causing the CI failures...

Tyler-IN commented 4 months ago

Difference in output in OpenApiGenerator.UnitTests.ClientTests.OpenAi; image

How do you want to address this @HavenDV ? Note the enums below too.

HavenDV commented 4 months ago

These tests are mainly for debugging/to see changes in data, so just accept the new changes or uncomment //.AutoVerify() before running and make sure there are no new diagnostics inside files like this Tests.YamlWithUrl_Diagnostics.verified.txt

HavenDV commented 4 months ago

Difference in output in OpenApiGenerator.UnitTests.ClientTests.OpenAi; image

How do you want to address this @HavenDV ? Note the enums below too.

It seems there is some kind of error with the OpenAI spec, and these models are skipped in the generation. I'll deal with this separately

Tyler-IN commented 4 months ago

Ok, with these changes CI should pass.

Tyler-IN commented 4 months ago

For note, the twitch integration tests are just placeholder filler.

The "test" was just compiling with the source generator.

HavenDV commented 4 months ago

The main place for testing in this project is the Snapshots tests, which compare the generated code and make sure that it does not produce any diagnostics (that is, it can compile). The tests here also allow you to debug the entire code, unlike integration tests, which use the generator itself without Roslyn

HavenDV commented 4 months ago

I will add twitch openapi spec to Snapshots tests little later today, I am at work now