Hacker Newsnew | past | comments | ask | show | jobs | submit | wing328hk's commentslogin

The new Python client should be easier to use and more pythonic.

Please give it a try to see if you like it.


One way is to auto-generate SDKs using OpenAPI Generator (http://github.com/openapitools/openapi-generator) given an OpenAPI spec.


If you want to generate a Crystal SDK for REST APIs, please give OpenAPI Generator [1] a try. Here are 3 simple steps to do so: https://forum.crystal-lang.org/t/crystal-api-client-generato....

Hopefully this will save you some time in manually creating the API clients in Crystal.

[1] https://openapi-generator.tech/


I agree with you that some generators are less mature. For example, we just added a Crystal client generator several weeks ago and we only have tests for posting a JSON body and getting it back to verify the result. Features like oneOf, anyOf are not yet supported (of course we welcome contributions to improve the Crystal client generator).

You can use customized templates (e.g. via -t option in the CLI) to meet your unique requirements. Another tips is to use code formatter such as https://prettier.io/, eslint etc to format the auto-generated code based on the style you want.

Please open an issue via http://github.com/OpenAPITools/openapi-generator/issues/new if you need help with OpenAPI Generator.

Disclosure: I'm the top contributor to OpenAPI Generator


You may want to give https://apitools.dev/swagger-parser/online/ a try to validate OpenAPI (fka Swagger) files.

You can do it online without a sign up or use the API or CLI according to your preference.


FYI. OpenAPI Generator supports many programming languages and server-side frameworks: https://github.com/OpenAPITools/openapi-generator#overview

This is not to say it has more languages supported than Protobuf as I do not know exactly how many generators out there supporting Protobuf.

(OpenAPI Generator also comes with the generator/converter that converts OpenAPI spec documents into gRPC and protocol buffer schema files. Not sure if OpenAPI Generator is also counted as a generator for Protobuf)


> Does OpenAPI generate code for you? I have worked on projects that use it and didn't have any generated code, so I am assuming not...

Please give OpenAPI Generator [1] a try to generate clients, servers stubs, documentation, schemas (graphql, protobuf, etc) and more. It supports many programming languages and many companies are already using it [2]:

[1] https://github.com/OpenAPITools/openapi-generator

[2] https://openapi-generator.tech/users

(Disclosure: I'm the top contributor to OpenAPI Generator)


If you want to access RESTful APIs via OCaml, you may consider using OpenAPI Generator to generate the OCaml client automatically instead of manually creating one. Here are 3 simple steps to do so:

1. Download the OpenAPI Generator CLI Java JAR (https://repo1.maven.org/maven2/org/openapitools/openapi-gene...)

2. Rename the JAR as "openapi-generator-cli.jar"

3. Run the following command to generate an OCaml API client for the Petstore API (https://raw.githubusercontent.com/OpenAPITools/openapi-gener...):

Mac/Linux:

$ java -jar openapi-generator-cli.jar generate -g ocaml -i https://raw.githubusercontent.com/OpenAPITools/openapi-gener... -o /var/tmp/ocaml/

Windows:

$ java -jar openapi-generator-cli.jar generate -g ocaml -i https://raw.githubusercontent.com/OpenAPITools/openapi-gener... -o C:\tmp\ocaml

If you've any feedback or question, please let us know via https://github.com/OpenAPITools/openapi-generator/issues/new


> Generators are still in need of work for the languages I use, but this is the future.

Please share your feedback by opening an issue via https://github.com/OpenAPITools/openapi-generator/issues/new.... Thanks.


Do you mind opening an issue via http://github.com/OpenAPITools/openapi-generator/issues/new with the details? (I assumed you've checked out the auto-generated documentation and that doesn't look good to you.)

There were discussions on type hints but unfortunately no one has found the time to make the contribution yet.

We also have a new `python-experimental` client generator that has better support for new features in OAS v3. Please check it out to see if it works better for you.


Thanks! I'll give the new generator a spin and see what it looks like.

IIRC the problems I faced were around things like bearer token auth with JWT being confusing to configure, the general structure of the client being unintuitive for me, and a general lack of examples on how the client was supposed to be used. No problems that I couldn't resolve each in an afternoon, but way harder to work with than a hand-rolled SDK (even considering complex and arguably a bit confusing ones like https://developer.paypal.com/docs/api/quickstart/).


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: