This project is a quick tool to generate Pharo classes from an OpenAPI description schema in Json, specific to one endpoint only. In its current form, you need to pass the description format as a FileReference or a String.
Next versions will add a data loader and a retrieval of all endpoint from cURL to the API.
Metacello new
githubUser: 'Evref-BL' project: 'OpenAPI-Class-Builder' commitish: 'main' path: 'src';
baseline: 'OpenAPIClassBuilder';
load
OpenApiClassesBuilder newClassNamed: 'CopilotsMetric' compileFromFilePath: '<path-to-your-json>/schema.json'.
extract the schema of data from the following REST API : Github-Copilot-Metrics.
place the JSON result in a local file schema.json
.
Build another file data.json
where you'll store the return data from the same API endpoint (or call the API from Pharo)
In Pharo; run:
"building class from schema file"
OpenApiClassesBuilder newClassNamed: 'CopilotsMetric' inPackage: #'Copilot-Github' withPrefix: 'CG' compileFromFilePath: 'shema.json'.
"test data import from the same API point"
CGCopilotsMetric importFromJSON: 'data.json' asFileReference contents.