How to reference the JSON schemas of objects from external sources (eg.GIT) into openapi yaml?

45 views
Skip to first unread message

Raghu Meda

unread,
Sep 26, 2017, 10:24:29 AM9/26/17
to Swagger
Hi,
Anyone have tried to include the references of JSON schemas of the objects from external sources (for eg. GIT lab)? I want to define the domain objects once in JSON schemas with version control in GIT lab and want to reference those object schemas in yaml so that we can maintain consistency across the yaml files for the same object definitions and its attributes. That also saves time for defining the specification and everyone in the team will use the same definitions across. 

Ron Ratovsky

unread,
Sep 27, 2017, 2:50:40 PM9/27/17
to swagger-sw...@googlegroups.com

It looks like gitlab gives you raw html links to files, so you can use that.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raghu Meda

unread,
Sep 28, 2017, 9:26:57 AM9/28/17
to Swagger
Thanks Ron for the reply. 
My usecase is that we want to define JSON schemas of data models for entities we want to use in Swagger yaml spec. Those JSON schemas will be managed in GIT for version control as we change the models regularly. So, my problem is to refer those data model schemas from GIT and use the attributes of the entities in yaml spec so that I need not to define them in every spec multiple times and achieve consistency across the specs prepared by different members of the team. It's like <include> feature in WSDL. I'm not looking for just the reference of the links in additional documentation in yaml.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Sep 28, 2017, 4:25:51 PM9/28/17
to swagger-sw...@googlegroups.com

JSON References allow you to reference any http url. This is not about additional documentation, this is about using $ref to reference those.

 

Keep in mind that if you’re using full JSON Schema, you won’t be able to reuse those in your Swagger definition as the specification does not support full JSON Schema.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Andrew Todd

unread,
Oct 4, 2017, 11:54:57 AM10/4/17
to swagger-sw...@googlegroups.com
I do not recommend that you do this in the way you are considering.

Let's imagine that you define three different APIs that use these common objects. Those three APIs are developed by different people, and accept changes at different speeds.

Someone makes a change to the common objects. This change adds a new field, and indicates (for example) that this field will always be present in all responses. However, maybe two of your three APIs aren't ready to return that new field yet. Maybe they weren't aware it was being added. Their API definition is now inaccurate.

There are strategies to provide common objects, but if you care about your API definitions being accurate and backwards-compatible, you must consider issues such as this.


On Tue, Sep 26, 2017 at 10:24 AM, Raghu Meda <raghu...@gmail.com> wrote:
Hi,
Anyone have tried to include the references of JSON schemas of the objects from external sources (for eg. GIT lab)? I want to define the domain objects once in JSON schemas with version control in GIT lab and want to reference those object schemas in yaml so that we can maintain consistency across the yaml files for the same object definitions and its attributes. That also saves time for defining the specification and everyone in the team will use the same definitions across. 

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages