Open AvdLee opened 1 year ago
Hmm this is interesting because an enum
with no values is not compliant with the OpenAPI 3.0 specification. I had a quick scan and can't find an explanation as to why in writing, but when loading the schema into VSCode with the OpenAPI plugin, it also alerts me to the issue:
That's because the specifications schema defines enum
with minItems
of 1
:
I wonder what the expected outcome is when having no items, because presumably you cannot decode any value into an empty enum?
In fact, it doesn't seem possible to conform to Codable
when there are no cases:
I guess the option here might be to patch the schema manually to remove that case, while filing a bug report with Apple? ๐
In the meantime, you might be able to unblock yourself by using the --allow-errors
option, but I've never used it before so I'm not sure if it will bypass this kind of error or not... Let me know how you get on though!
I found the docs for the endpoint that uses this enum:
It seems that fields[subscriptionOfferCodeOneTimeUseCodeValues]
is documented as a plain string, and not an enum:
It could be that other tools consider an empty enum
as just a regular string.. Which I guess we could implement if it does come to it, but first its probably worth trying to get the schema fixed upstream to match the documentation
I raised FB10631712
fields[subscriptionOfferCodeOneTimeUseCodeValues]
parameter ofv1/subscriptionOfferCodeOneTimeUseCodes/{id}
is incorrectly defined as an empty enum in the v2 specificationBasic Information
Please provide a descriptive title for your feedback:
fields[subscriptionOfferCodeOneTimeUseCodeValues]
parameter ofv1/subscriptionOfferCodeOneTimeUseCodes/{id}
is incorrectly defined as an empty enum in the v2 specificationWhich area are you seeing an issue with?
App Store Connect API
What type of feedback are you reporting?
Incorrect/Unexpected Behavior
Description
Please describe the issue:
Thanks for releasing all the new endpoints in v2 of the API! Weโre trying to use the CreateAPI tool to generate Swift code from the schema document however have ran into an issue with the
v1/subscriptionOfferCodeOneTimeUseCodes/{id}
endpoint.The
fields[subscriptionOfferCodeOneTimeUseCodeValues]
parameter is defined as anenum
with no values. But itโs documented as a plain string in the API documentation (https://developer.apple.com/documentation/appstoreconnectapi/read_one-time_use_offer_code_information).Since an enum with no values is not valid as part of the OpenAPI specification, I am going to assume that this is a mistake and the
enum
keyword should be removed:{ "name" : "fields[subscriptionOfferCodeOneTimeUseCodeValues]", "in" : "query", "description" : "the fields to include for returned resources of type subscriptionOfferCodeOneTimeUseCodeValues", "schema" : { "type" : "array", "items" : { "type" : "string", - "enum" : [ ] } }, "style" : "form", "explode" : false, "required" : false }
But I guess it could also be that there are supposed to be some specific values? Either way I think there is something that needs changing ๐๐ปโโ๏ธ
You can find some more details here: https://github.com/CreateAPI/CreateAPI/issues/55
Please list the steps you took to reproduce the issue:
- Downloaded the v2 API schema
- Ran it through a validator
- Observed that an empty enum array is not valid in the spec
What did you expect to happen?
A valid Open API Specification (either removing the enum keyword or defining at least one value in the array)
What actually happened?
The schema was not valid because at least 1 item was expected in the enum array
I decided to add an empty
case manually in the specs, which keeps everything working! Let's hope Apple solves it in the spec later ๐
See the following output:
Mostly due to:
The specification used can be found here