There actually isn’t a direct way of doing that, mostly because this is an API 
descriptor and not a model descriptor. 

In OAS3 there’s a new construct called Links that allows you to describe 
mapping from responses to future requests, that may satisfy your needs.

You can read more about it at https://swagger.io/docs/specification/links/.

 

 

 

From: <swagger-swaggersocket@googlegroups.com> on behalf of "366j...@gmail.com" 
<366j...@gmail.com>
Reply-To: "swagger-swaggersocket@googlegroups.com" 
<swagger-swaggersocket@googlegroups.com>
Date: Tuesday, November 28, 2017 at 20:21
To: Swagger <swagger-swaggersocket@googlegroups.com>
Subject: How to describe foreign Key realtions?

 

Lets just say I have 2 Defintions with corresponding paths set up:

//Paths: /users
//       /groups

"User": {
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Id of this Userr"
                },
                "groupId": {
                    "type": "string",
                    "description": "The Id of the group, this user belongs to",
                    "references": {
                         "path": "/groups",
                         "field": "id"
                     }
                },
                "name": {
                    "description": "name of the user",
                    "type": "string",
                    "example": "Doe"
                }
                
        },
"Group": {
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Id of this Group"
                },
         
                "name": {
                    "description": "name of this group",
                    "type": "string",
                    "example": "TestGroupName"
                }
                
        },


Not that field "references" is pseudo code, completely made up by me, but it 
tells you what I want to accomplish: I want to somehow encode the information 
of where to look for possible valid Values for this parameter by referencing 
another path in the given api.

I am pretty sure I am just being a fool and there is an obvious, official way 
to this, but I just cant seem to find it.

-- 
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+unsubscr...@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-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to