I did generate a pretty nice-looking C# OpenAPI library (maybe make it officially generated by peppy someday), but there is a couple of problems along the journey.
/// <summary>
/// Initializes a new instance of the <see cref="GetTopicAndPosts200ResponseTopic" /> class.
/// </summary>
/// <param name="id">id.</param>
/// <param name="">.</param>
public GetTopicAndPosts200ResponseTopic(int id = default(int), string = default(string))
{
this.Id = id;
this.___ = ;
}
After fixing both problem we see another problem with body parameter not well-parsable:
/// <summary>
/// Initializes a new instance of the <see cref="GetBeatmapAttributesRequest" /> class.
/// </summary>
/// <param name="mods">Mod combination. Can be either a bitset of mods, array of mod acronyms, or array of mods. Defaults to no mods..</param>
/// <param name="ruleset">Ruleset of the difficulty attributes. Only valid if it's the beatmap ruleset or the beatmap can be converted to the specified ruleset. Defaults to ruleset of the specified beatmap..</param>
/// <param name="rulesetId">The same as `ruleset` but in integer form..</param>
public GetBeatmapAttributesRequest(Collection<NumberStringMod> mods = default(Collection<NumberStringMod>), GameMode ruleset = default(GameMode), int rulesetId = default(int))
{
this.Mods = mods;
this.Ruleset = ruleset;
this.RulesetId = rulesetId;
}
/// <summary>
/// Mod combination. Can be either a bitset of mods, array of mod acronyms, or array of mods. Defaults to no mods.
/// </summary>
/// <value>Mod combination. Can be either a bitset of mods, array of mod acronyms, or array of mods. Defaults to no mods.</value>
/// <example>1</example>
[DataMember(Name = "mods", EmitDefaultValue = true)]
public Collection<NumberStringMod> Mods { get; set; }
/// <summary>
/// Ruleset of the difficulty attributes. Only valid if it's the beatmap ruleset or the beatmap can be converted to the specified ruleset. Defaults to ruleset of the specified beatmap.
/// </summary>
/// <value>Ruleset of the difficulty attributes. Only valid if it's the beatmap ruleset or the beatmap can be converted to the specified ruleset. Defaults to ruleset of the specified beatmap.</value>
/// <example>osu</example>
[DataMember(Name = "ruleset", EmitDefaultValue = true)]
public GameMode Ruleset { get; set; }
So this is not an easy problem to solve for now. I simply just yeeted all NumberStringMod into string and hope it will work. After that all the source code can be compiled and I got a semi-working osu API v2 client in C#!
I really want to make a discussion thread instead of putting this as an issue but whatever for now.
I want to generate a C# OpenAPI client through the use of OpenAPI and the OpenAPI Generator, here's the command I used:
config.yaml:
I did generate a pretty nice-looking C# OpenAPI library (maybe make it officially generated by peppy someday), but there is a couple of problems along the journey.
First it seems like HTML inside an example is not parsed correctly: https://github.com/ppy/osu-web/blob/708f7f859e2cbfc27b4b32f297a2b7c1ae98ea2c/resources/views/docs/_structures/changelog_entry.md?plain=1#L13
Results in this:
Another problem is that the response format for TopicsController\show is not well formed: https://github.com/ppy/osu-web/blob/708f7f859e2cbfc27b4b32f297a2b7c1ae98ea2c/app/Http/Controllers/Forum/TopicsController.php#L294-L303
Which results in this:
After fixing both problem we see another problem with body parameter not well-parsable:
https://github.com/ppy/osu-web/blob/708f7f859e2cbfc27b4b32f297a2b7c1ae98ea2c/app/Http/Controllers/BeatmapsController.php#L34-L59
This is however not a solvable issue because C# did not support discriminated union which is proposed (but it exists in F#): https://github.com/dotnet/csharplang/blob/main/proposals/discriminated-unions.md
So this is not an easy problem to solve for now. I simply just yeeted all NumberStringMod into string and hope it will work. After that all the source code can be compiled and I got a semi-working osu API v2 client in C#!
@jimschubert Should I cross reference this to https://github.com/OpenAPITools/openapi-generator team?
Another small issue is that I did not see the GameMode definition in the OpenAPI schema either so the class
GameMode
for theRuleset
doesn't really exists for some reason, but it is here as an enum: https://github.com/ppy/osu-web/blob/HEAD/resources/js/interfaces/game-mode.ts