Open ferranpujolcamins opened 4 years ago
Thanks for reporting! We'll take a look, but it may be due to the underlying tool we are using.
Ey @ferranpujolcamins ! You are putting on limit the library, nice!
Currently, we do not support OneOf
, but you can use enum
; I know you can not use it with associated complex types, but maybe you can find a workaround (think about it as DTO)... I will show you an example:
Given the next Apple SignIn service: https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens
You can look at the field grant_type
, defined as enum
in order to restrict possibilities for requests.
AppleSignInAuth:
type: object
required:
- client_id
- client_secret
- grant_type
- code
- redirect_uri
properties:
client_id:
type: string
description: The application identifier for your app.
client_secret:
type: string
description: A secret generated as a JSON Web Token that uses the secret key generated by the WWDR portal.
grant_type:
type: string
description: The grant type that determines how the client interacts with the server. For authorization code validation, use authorization_code. For refresh token validation requests, use refresh_token.
enum:
- authorization_code
- refresh_token
code:
type: string
description: The authorization code received from your applicationās user agent. The code is single use only and valid for five minutes.
redirect_uri:
type: string
description: The destination URI the code was originally sent to. It must include a domain name, and canāt be an IP address or localhost.
Another example, in the response: https://developer.apple.com/documentation/sign_in_with_apple/errorresponse
We could define the error as
AppleSignInError:
type: object
required:
- error
properties:
error:
type: string
description: A string that describes the reason for the unsuccessful request. The string consists of a single allowed value.
enum:
- invalid_request
- invalid_client
- invalid_grant
- unauthorized_client
- unsupported_grant_type
- invalid_scope
Given the following schema:
The YYYYMMDD struct is generated correctly. But then, bow-openapi generates two empty structs WRAPPER and OneOfWRAPPER.
I would expect WRAPPER to be an enum with a case with an associated value of YYYYMMDD.