Forum Discussion

Nixol's avatar
Occasional Contributor
4 years ago

Can I split my swagger (openapi 3.0.3) spec over multiple YAML files?

I currently have an API  spec in YAML which is becoming too large.  I am just wondering if it is possible to split the specification into smaller YAML files and still achieve the same result.  Can this be done?

2 Replies

  • Hi, Yes you can split your main yaml file into others by using the $ref field in the objects that apply.

    • Nixol's avatar
      Occasional Contributor

      Thanks GraceKarina .  When trying to use the $ref, I got this error message: 

      Could not resolve reference: Tried to resolve a relative URL, without having a basePath. path: '/Users/xxxxxxx/Downloads/abcdef.yaml' basePath: 'undefined'.

      The file I am trying to reference is in the folder "/Users/xxxxxxxx/Downloads/", Is there anything I am doing wrong?  Is there any example I  can see?