Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation and use docs #24

Open
gbosetti opened this issue May 28, 2020 · 1 comment
Open

Installation and use docs #24

gbosetti opened this issue May 28, 2020 · 1 comment

Comments

@gbosetti
Copy link

gbosetti commented May 28, 2020

Hello and congrats for your project! It seems you are pioneering openapi in Smalltalk :) I would like to try to use your project for both, generating the docs and generating the API code in Smalltalk. Just in case, do you have some base guidelines to generate the code? This is what I did right now (it could be useful for the readme if you think it can help other developers):

  1. Use Iceberg to load the repo. It is simpler via https
  2. Click on the repo > Metacello > Install baseline
  3. You can check the tests, or you can set up a server from the Playground with the example API, and check it from your Web browser:

server := ZnServer startOn: 1700 + 10 atRandom.
server delegate:
(ZnRestServerDelegate new
uriSpace: ( OpenAPIUriSpace new
rootClass: OpenAPICall;
yourself )).

Pet instances add: (Pet new id: 1; name: 'a'; age: 1).
Pet instances add: (Pet new id: 2; name: 'a'; age: 2).

server localUrl. // e.g. Visit http://localhost:1710/pets/01

  1. If you want to load your own OpenAPI specification, lets say:
    fileContent := '{ "openapi": "3.0.0", ...}'.

You can do it by loading from a string:
api := OpenAPI fromString: fileContent.

Bue then... I couldn't find the way to generate the supporting classes (e.g. Pet, OpenAPISpecCall, etc). Or is it something we should manually create?

Thanks!

@noha
Copy link
Member

noha commented Jun 4, 2020

Hello! Sorry for replying so late. Thanks! Yes, I try to make OpenAPI available in Pharo which is not a small endavor but a useful one. And I'm looking for users like you to improve code. If you are not in a hurry, please give me time to prepare a bit of documentation. It is lacking anyway so now I should add it.
About creating classes. I'm not a big fan of creating classes. If you create something static from a dynamic model I would question if it isn't better to stick with the dynamic one. The target for this OpenAPI port was not to create REST classes from the spec but produce the spec from the REST classes. The definition on the class side of the pets classes define the parameters of the calls and their constraints. These are used to read and write data of the REST interface to make sure the data delivered is what the spec tells. The client for OpenAPI consumes a spec and creates a runtime model where you create methods with less overhead to make the calls. As usually clients need to tweak data something generated always steps in the way so again I'm not a friend of this. But there is still potential you can convince me ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants