ogen-go / ogen

OpenAPI v3 code generator for go

Home Page:https://ogen.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

External references don't work

ruckc opened this issue · comments

What version of ogen are you using?

1.0.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

I have an openapi.yaml with a reference to another file.

What did you expect to see?

I expected the $ref to resolve the reference to the external file.

What did you see instead?

  - openapi.yaml:104:13 -> $ref: resolve "./type.json": get "file:///home/user/project/type.json": external references are disabled

What I did after getting the error...

I grepped the ogen source, found the error being raised in openapi/parser/settings.go from the NoExternal ExternalResolver implementation.

I can not figure out how to pass that in to ogen. I tried a config.yaml that looked like the below, based on the example configs and the exampes showing infer_types and depth_limit.

It would be nice if it was documented how to set the external resoler.

parser:
  external: true

Here's full config example.
allow_remote is what you need.

# sets parser options.
parser:
# enables type inference for schemas. Schema parser will try to detect schema type by its properties.
infer_types: true
# enables remote references resolving. See https://github.com/ogen-go/ogen/issues/385.
allow_remote: true
# is maximum depth of schema generation. Default is 1000.
depth_limit: 1000

ok... that would be a naming inconsistency... I saw allow_remote, but it didn't align to anything in settings.go... and the description (enables remote references) doesn't describe the error (external references are disabled)