© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3mo ago
bin

OpenAPI generator for C#, having issues with an endpoint that returns two types

Hi everyone,

I'm working on a fork of a generated library and attempting to bring my own changes to it, by creating a wrapper for .NET DI and and cleaning up how the API is used.

If you look at https://github.com/vrchatapi/vrchatapi-csharp/ you can see the generated API is quite a bit messy and the maintainers don't have much experience with C#.

My fork: https://github.com/binn/vrchatapi-csharp

I was successfuly able to implement my wrapper classes (in the wrapper/ directory, auto copied over to src/VRChat.API/Client directory on build), and upgrade openapi-generator from 6.x.x to 7.1.x

I've migrated the library to .NET 8.0 and added a couple dependencies, these patches can be found in the
generate.sh
generate.sh
file.

I'm aware Kiota exists and I tried it out, but it doesn't seem to generate what we're looking for and is probably not the right direction for us at this time. I wasn't sure how to make it generate in a different way but in Kiota it breaks down the path as classes, like instead of
_vrchat.Authentication.GetCurrentUser
_vrchat.Authentication.GetCurrentUser
it's more like
_client.Auth.User.GetAsync()
_client.Auth.User.GetAsync()
(or more confusing
_client.Auth.Twofactorauth.Verify.PostAsync()
_client.Auth.Twofactorauth.Verify.PostAsync()
and it doesn't seem to support what I'm trying to do here.

We have an endpoint, the endpoint for logging into VRChat https://vrchat.community/reference/get-current-user

This endpoint actually returns two different types. If unauthenticated, it returns 401, but if authenticated with a Basic header with user/pass, it will return just
{"requiresTwoFactorAuth":[ "emailOtp", "totp" ]}
{"requiresTwoFactorAuth":[ "emailOtp", "totp" ]}
instead of the CurrentUser object.

Once you get the
{"requiresTwoFactorAuth":[ "emailOtp", "totp" ]}
{"requiresTwoFactorAuth":[ "emailOtp", "totp" ]}
response, you get returned a temporary auth cookie and you need to call another endpoint to verify twofactorauthentication which will return an
auth
auth
and
twoFactorAuth
twoFactorAuth
cookie for you to store. Then you're logged in

Once you're logged in, you can simply just use your cookies and call the
GetCurrentUser
GetCurrentUser
endpoint again to retrieve the current user.

1) No, there are no API keys for VRChat. It's a social video game with an unsupported unofficial API
2) All accounts have two factor authentication, either via email or TOTP
3) I'm the only active maintainer on the C# repo, everything else is hung by a thread and autogenerated

I'm aware that there is a
oneOf
oneOf
in openapi spec but the generator doesn't support it and I'm pretty sure Kiota doesn't support it either. We also can't change the spec to do this just for C# because some of the other languages don't support the
oneOf
oneOf
parameter.

But because it returns these two seperate types, it breaks because it's expecting a CurrentUser object, and the CurrentUser object has a bunch of
IsRequired = true
IsRequired = true
on the DataMember attributes

My current hacky solution is to use sed as a patch to set them all to false in CurrentUser.cs and add in a
requiresTwoFactorAuth
requiresTwoFactorAuth
property to the class that's also optional.

ChatGPT and Claude asked me to make wrapper methods and change the spec, but wrapper methods may not be used by all, and I can't ensure a way to keep the cookies part of the pipeline the way the autogenerated lib has it.
But I feel like there must be a better way? If anyone has any ideas let me know.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

OpenApi Login endpoint with cookies
C#CC# / help
2mo ago
issues with code generator
C#CC# / help
10mo ago
Authorised endpoint returns 401
C#CC# / help
3y ago
Data types in C#
C#CC# / help
13mo ago