https://github.com/evref-bl/openapi-class-builder
A tiny tool to generate Pharo classes from an OpenAPI json schema description
https://github.com/evref-bl/openapi-class-builder
Last synced: 10 months ago
JSON representation
A tiny tool to generate Pharo classes from an OpenAPI json schema description
- Host: GitHub
- URL: https://github.com/evref-bl/openapi-class-builder
- Owner: Evref-BL
- Created: 2025-05-07T13:12:47.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-15T06:55:13.000Z (about 1 year ago)
- Last Synced: 2025-06-17T16:44:56.253Z (about 1 year ago)
- Language: Smalltalk
- Size: 27.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UPDATE
This project is a POC, only working on Small part of the OpenAPI specification (i.e. example from Github OpenAPI UI browser). Please report to this project instead for the latest implementation [https://github.com/Evref-BL/pharo-openapi-generator](https://github.com/Evref-BL/pharo-openapi-generator)
# Description
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.
# Installation
```smalltalk
Metacello new
githubUser: 'Evref-BL' project: 'OpenAPI-Class-Builder' commitish: 'main' path: 'src';
baseline: 'OpenAPIClassBuilder';
load
```
# Usage
```smalltalk
OpenApiClassesBuilder newClassNamed: 'CopilotsMetric' compileFromFilePath: '/schema.json'.
```
# Example
extract the schema of data from the following REST API : [Github-Copilot-Metrics](https://docs.github.com/fr/enterprise-cloud@latest/rest/copilot/copilot-metrics?apiVersion=2022-11-28#get-copilot-metrics-for-an-enterprise).
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:
```smalltalk
"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.
```