There really needs to be an Idiot's Guide for using Packs

I’m trying to use the openapi pack and from the documentation it looks dead simple:

swipl openapi --server=server.pl spec.yaml

But it’s taken me an inordinate amount of time to end up with something that doesn’t work anyway. The first problem is that swipl pack install seems to ignore any proxy settings in the environment, and I can’t find any way of specifying a proxy on the command line.

The second problem is once I have the pack installed in the packs subdir of $PWD, how do I run it?

$ swipl openapi -h
ERROR: Prolog initialisation failed:
ERROR: file `openapi' does not exist

or:

$ swipl packs/openapi/app/openapi.pl
ERROR: /tmp/odaas/packs/openapi/app/openapi.pl:36:
ERROR:    source_sink `library(openapi)' does not exist
Warning: /tmp/odaas/packs/openapi/app/openapi.pl:36:
Warning:    Goal (directive) failed: user:use_module(library(openapi))
OpenAPI -- generate REST servers and clients

Turns out I have to export SWIPL_PACK_PATH=$PWD/packs but it took me an age to find that in the docs.

And after all that:

$ swipl openapi --server=server.pl --http --ui spec.yaml
ERROR: /tmp/openapi/packs/openapi/app/openapi.pl:40: user:main: false
$

Bah :frowning:

p.s. it’s the C function yaml_parse_stream() that’s failing. The YAML I’m feeding is valid - I’ve passed it through several YAML validators and they all give it a clean bill of health - so there’s a bug somewhere in yaml_parse_stream().