Current Sync Gateway OpenAPI (Swagger) yaml definition contains errors

I encountered errors generating a c# client from the current version of sync-gateway-public.yaml using both AutoRest and NSwagStudio. When I validated the yaml content with https://editor.swagger.io, I can see that several errors were reported (as attached below). After manually fixing those errors on my own copy of the yaml, I was able to at least generate client codes for my project using NSwagStudio. (AutoRest still failed with an error which I didn’t go deeper to find out a solution)

Even though I was able to get past those errors for my purpose, I thought I should report this problem so that the Couchbase team can address them accordingly.

Details about the problem:

  1. Download the yaml from:
    https://docs.couchbase.com/sync-gateway/current/_attachments/sync-gateway-public.yaml
  2. Use AutoRest to generate a client (c# in this case):
    autorest --csharp --output-folder=.\sgclient --input-file=sync-gateway-public.yaml --namespace=myproject --add-credentials
  3. With NSwagStudio, I could generate output but all the operations are named like this: AnonymousXXAsync.

Some errors reported by https://editor.swagger.io and what I did to my own copy of yaml to get rid of the errors:

  1. Changed parameters.since.type from object to string
  2. Fixed several misspelled ‘description’ properties to ‘description’
  3. Added meaningful, unique operationId to all operations
  4. Removed some unsupported properties ‘name’
  5. Added the missing ‘items’ field at additionalProperties.properties.missing

I also found out that the optional property ‘deleted’ is missing from the ChangesFeedRow definition. I think I need to use that to determine the type of a change.

I hope this helps anyone encountering the same issue.
Andy

Thanks for sharing this update. Can you also share the updated version of the swagger spec / .yaml. As indicated in the docs, the swagger spec isn’t officially supported or actively maintained. It is offered as a convenience/ starting point for developers. If you share the updated version, we could publish that as a starting point

(CC @ibsoln )

Certainly. But please take my changes with a grain of salt. Some of them may not be correct. I only tested what I needed for my project.
:slight_smile:

https://pastiebin.com/601b7cae318a2

Thanks for the information. I’ll follow this up in the docs.
Contributions such as this from the community are always welcome.