zweidenker / openapi Goto Github PK
View Code? Open in Web Editor NEWA pharo implementation of OpenAPI 3.0.1
License: MIT License
A pharo implementation of OpenAPI 3.0.1
License: MIT License
Currently dateAndTime is handled via formatString but OpenAPI defines it as primitive type
Needs to be defined when a read:schema: in the json schema is appropriate and when is the conversion from OpenAPI string done.
A unit schema is property value (a number) and property unit (an enum).
Would be useful to define volume Units, distance units etc as json schema. It should be easy to add properties like ranges etc on top
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):
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
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!
Construction of the request body is too complicated. Should be doable by method, mime type and schema
Since the separation of JSON schema and OpenAPI the exception handling is not working as expected. There are new exception from JSON schema that should be caught as well. Most constraint errors or type errors could be automatically translated into 400 status code responses with error description
JSON schema defines properties for type and some value formats. The code should be flexible enough so it is possible to define custom constraints and add it to a property. Custom constraints should carry a label that can be added in e.g. the description
In order to validate/describe outgoing objects Response Object needs to be implemented
At the moment $ref is handled by pre parsing JSON to detect if the first key is $ref. But this is a wrong assumption. Doing it properly will mean to add a visitor that post-processes the OpenAPI after it is read from JSON
we are missing #OASchema>>number
OpenAPI has been implemented from scratch as OpenAPI without determine which of the structure is lend from JSON schema. Both should be separated and packaged in separate repositories
Current NeoJSON materialization tries to detect $ref elements directly which does not work. There is now a visitor doing it properly. Left-overs from the old handling need to be removed
We are missing enum type like:
#OASchema>>enum: #(this is an enum)
API objects in OpenAPI can be defined in place or referenced via the $ref key. The implementation needs to take care to materialize the right type
There is a pragma based builder that helps constructing the parameters and request body of an OpenAPI call. Another method is needed to access the path item object itself in order to add descriptions and such
When I run:
Metacello new
baseline: 'OpenAPI';
repository: 'github://zweidenker/OpenAPI/';
load.
I am getting what appears to be an Ombu error:
ZnBufferedReadWriteStream(Object)>>doesNotUnderstand: #defaultBufferSize
ZnBufferedReadWriteStream>>on:
ZnBufferedReadWriteStream class>>on:
FileReference>>binaryReadWriteStream
[ | initialPosition initialLocalName fileStream |
self entryBuffer isEmpty
ifTrue: [ ^ self ].
fileStream := ZnCharacterReadWriteStream
on: fileReference binaryReadWriteStream
encoding: #utf8.
[ | anEntryWriter |
fileStream setToEnd.
initialPosition := fileStream position.
initialLocalName := self entryBuffer first value.
anEntryWriter := self newEntryWriter.
[ self entryBuffer isEmpty ]
whileFalse: [ | next entry |
next := self entryBuffer removeFirst.
entry := next key.
"Write entry to file"
anEntryWriter on: fileStream nextEntryPut: entry ].
"In Linux it was necessary to explicitely flush the file stream"
fileStream flush.
lastStreamPosition := fileStream size ]
ensure: [ fileStream close ].
self
refreshEntryPositionsByLocalNameStartingAt: initialPosition
since: initialLocalName ] in OmBlockFileStore(OmFileStore)>>flushEntryBuffer in Block: [ | initialPosition initialLocalName fileStream |...
[ caught := true.
self wait.
blockValue := mutuallyExcludedBlock value ] in Semaphore>>critical: in Block: [ caught := true....
BlockClosure>>ensure:
Semaphore>>critical:
OmBlockFileStore(OmFileStore)>>critical:
OmBlockFileStore(OmFileStore)>>flushEntryBuffer
OmDeferrer>>sendMessage
[ self sendMessage ] in OmDeferrer>>flush in Block: [ self sendMessage ]
BlockClosure>>ensure:
OmDeferrer>>flush
[ "Loop until enough time passed since last #schedule"
[ DateAndTime now < (lastSchedule + duration) ]
whileTrue: [ duration wait ].
"Execute deferred action (if not flushed before) and clean up"
self flush ] in OmDeferrer>>runMessageProcess in Block: [ "Loop until enough time passed since last #sched...etc...
[ self value.
Processor terminateActive ] in BlockClosure>>newProcess in Block: [ self value....
At the moment we only have JSON schema type and value constraints per property. An additional checking of constraints for the resulting object is needed
There is no supported to define responses of a call by status code
Implement allOf: schema type.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.