Patch OpenAPI spec instead of writing custom code
In https://github.com/vrchatapi/vrchatapi-rust/pull/12 custom code was introduced to fix https://github.com/vrchatapi/specification/issues/241.
I have opened https://github.com/vrchatapi/specification/pull/352, but we noticed that some of the generators do not support the oneOf. Its reasonable to assume that this is on hold until upstream generators of all supported languages can deal with oneOf.
This change generates code that is similar to what was added manually but does this via patching the spec instead. IMHO this a more maintainable way of achieving the same goal. Please give feedback.
EDIT: Based on these DC Messages: One, Two I opted to use JSONPatch instead of a regular patch as it was mentioned they are quite hard to maintain.
The dart package used to do this, so I see no issue
We could add this to the specification repository and, during bundling, create two specs. Generators that support oneOf can then use the feature-enabled spec.
Something like:
/auth/user:
get:
summary: Login and/or Get Current User Info
tags:
- authentication
x-codeSamples:
$ref: "../codeSamples/authentication.yaml#/~1auth~1user/get"
responses:
'200':
x-feature:
key: oneOf
schema:
oneOf:
- $ref: ../responses/authentication/CurrentUserLoginResponse.yaml
- $ref: '#/components/schemas/TwoFactorRequired'
fallback:
$ref: ../responses/authentication/CurrentUserLoginResponse.yaml
'401':
$ref: ../responses/MissingCredentialsError.yaml
then during bundling/building, we're turn this into two specification files.
I think fixing this here is not a good solution at this point in time and is not implemented in a clean way. Closing for now.