apigear-io / cli

The ApiGear client as go project
https://apigear.io
MIT License
1 stars 2 forks source link

allow external meta document #140

Open jryannel opened 6 months ago

jryannel commented 6 months ago

An external meta data document allows developers to inject meta information to models without storing them inside a model. The meta information is injected based on json paths into the external documents.

meta.yaml

select: demo.Counter.value meta: min: 0 max: 100

jryannel commented 5 months ago

You can use solution targets to specify import meta documents:

// demo.solution.yaml
schema: apigear.solution/1.0
targets:
  - name: demo
    imports: [meta.yaml]
    meta:
      go:
        module: rpc
    inputs:
    - api/a.idl
    - api/b.idl
    output: out
    template: templ

The meta document is a map of node fully qualified names with attached meta documents:

// meta.yaml
demo.bbb.Counter#value:
  hello: world

This will allow you to print the meta information for the interface member:

// demo.go.tpl
{{- range .Properties }}
    {{ printf "%v" .Meta.hello}}
{{- end }}