openapi2cl icon indicating copy to clipboard operation
openapi2cl copied to clipboard

`generate` mandates all its elements

Open mooseyboots opened this issue 10 months ago • 0 comments

while trying to get this library running against https://codeberg.org/swagger.v1.json, i found that generate mandates host basePath consumes produces, schemes. the codeberg/forgejo swagger has no host, so gethash errors.

so this:

  (let* ((host (gethash "host" openapi))
         (base-path (gethash "basePath" openapi))
         (consumes-media-types (gethash "consumes" openapi))
         (produces-media-types (gethash "produces" openapi))
         (schemes (or (gethash "schemes" openapi)
                      '("https")))

became:

  (let* ((host (or (gethash "host" openapi) ""))
         (base-path (gethash "basePath" openapi))
         (consumes-media-types (gethash "consumes" openapi))
         (produces-media-types (gethash "produces" openapi))
         (schemes (or (gethash "schemes" openapi)
                      '("https")))

i also found i had to add a similar or clause in security-schemas-from-hash-table:

 (make-instance 'security-schema
                                :name (gethash "name" schema)
                                :in (kebab-symbol-from-string (or (gethash "in" schema) "") :openapi2cl/core)

perhaps some other such elements are also not mandatory, i'm not sure as i've only tested the one spec so far.

mooseyboots avatar Mar 05 '25 10:03 mooseyboots