Skip to content

Feature request: build a Model without resolving external references #519

@mromaszewicz

Description

@mromaszewicz

Hi Guys,

I'm the author of an OpenAPI spec to Go code generator (https://github.com/oapi-codegen/oapi-codegen), and I'm working on V3.1 and V3.2 support by switching to your wonderful library.

One place where I have trouble is with handling external references. Let's say that I have a spec that looks like this:

components:
  schemas:
    ObjectA:
      properties:
        name:
          type: string
        object_b:
          $ref: ../packageB/spec.yaml#/components/schemas/ObjectB

As a code generator, I don't care about the contents of that external spec. All I know is that there is an ObjectB defined somewhere else, and I just need to import a package and reference it, I don't need to fetch and parse its spec.

This is a use case in oapi-codegen which comes up a bunch. Someone might have hand implemented something that they're referring to via spec and the spec may not exist, or may no longer be available.

Right now, my libopenapi port sets up the BasePath and relies on the specs being available, but this will be a regression in our behavior.

I've considered other workarounds; rewriting the spec before parsing to use a stub schema, or not calling BuildV3Model() at all, which bypasses your parsing and validation, but this is a big loss for me.

In an ideal world, I would love to see some kind of flag which says to skip resolving external schemas, and in the resulting Document, I'd have some kind of node which has Ref=something, but a flag indicating that it's external, or simply a nil Schema?

How would you do this? I'm happy to send a PR if you can suggest a way compatible with your design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions