Skip to main content
Solved

Generate client from CDF openapi spec for Go

  • November 30, 2023
  • 1 reply
  • 92 views

I am unable to generate client code for the CDF openapi spec at https://api-docs.cognite.com/20230101/ using deepmap/oapi-codegen for Go, seemingly because the spec contains some errors. Do anyone know of a way to generate an api-client in go for the CDF-api spec?

 

Both commands below rely on having openapi spec downloaded to the current directory from https://api-docs.cognite.com/20230101/

 

Testing the spec for errors with redocly/cli: docker run --rm -it -v $PWD/swagger.json:/swagger.json redocly/cli lint /swagger.json

For me this results in “Validation failed with 25 errors and 382 warnings”

 

Generating the client library using deepmap/oapi-codegen: go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.0.0 --config oapi-codegen-config.yaml swagger.json

with the this config file:

package: "cdf_api"
output: "cdf_api.gen.go"
generate: 
  models: true
  client: true
compatibility:
  circular-reference-limit: 100

For me this results in the message “error generating code: error creating operation definitions: path '/documents/search' has 0 positional parameters, but spec has 1 declared” - I started fixing some errors, but there was quite a few of them, so I stopped.

 

 

Best answer by Dilini Fernando

Hi @andcondall,

Our product teams are working hard to make sure our APIs meet the OpenAPI spec, but every now and then we might run into some issues. If you come across any specific, critical non-conformities, we'd really appreciate it if you could log a ticket for us or send an email to support@cognite.com . This will help us prioritize and address them properly among other items in our bug backlog.

View original
Did this topic help you find an answer to your question?

1 reply

Dilini Fernando
Seasoned Practitioner
Forum|alt.badge.img+2
  • Seasoned Practitioner
  • 671 replies
  • Answer
  • June 17, 2024

Hi @andcondall,

Our product teams are working hard to make sure our APIs meet the OpenAPI spec, but every now and then we might run into some issues. If you come across any specific, critical non-conformities, we'd really appreciate it if you could log a ticket for us or send an email to support@cognite.com . This will help us prioritize and address them properly among other items in our bug backlog.


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings