vrchatapi / specification

⚙️ VRChat API OpenAPI specification defining the API in a machine-readable format. This is then used for automatic generation of language-specific SDK's
MIT License
46 stars 31 forks source link

RFC: Feature-enabled specification variants. #370

Open ariesclark opened 1 month ago

ariesclark commented 1 month ago

Some generators support certain syntax's that others don't, to provide the best support possible and closely model VRChat's API, relying on the most minimum support available across all generators leaves us with undesirable/broken SDKs.

I propose something similar to the following:

/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.

Resources

Originally posted by @ariesclark in https://github.com/vrchatapi/vrchatapi-rust/issues/17#issuecomment-2246337894

Alternatives

ariesclark commented 1 month ago

cc: @Foorack thoughts, concerns?

0xkubectl commented 1 month ago

Is there any other potential application for this besides responses?

C0D3-M4513R commented 1 month ago

Is there any other potential application for this besides responses?

This could be used to implement tag parsing too, by using one_of to either parse to an enum or a string as a fallback.

See the following commits: