Constructing Responses from properties in different datatype files


#1

I have created a number of datatype files that I have imported into my api.raml file. I would like to use elements of each as for different endpoints. I have tried a number of different approaches that have failed:

  1. Create another datatype file that could be used to construct a tailored response for each endpoint. It would have to have duplicate entries with other datatype files which does not make sense.

  2. It is not possible to use “uses” and break this into libraries or in a datatype file otherwise reference other files that I have found out.

Here is a conceptual example (that does not show errors in Studio - but of course does in the API Manger):

responses: 
  200: 
    body:
     application/json:
       type: object
       properties: 
        studentID: publishedInstructor.instructorID
        courses: courseinformation.courseID[]

In other words, I want a response that includes the instructorID from the publishedInstructor datatype file (I have messed with capitalization without fixing this (i.e., the datatype files have an initial capitol). For this instructorID, I would like to return an array of course information.


#2

I would gladly help. Do you mind sharing your RAML libraries?


#3

Thank you very much. I am trying to experiment to see if I can used libraries to help with this. no luck yet. For example I would like to use for example. one property for datatype file 1 and one property from datatype file number two. Say courseID from the CourseInformation.raml and studentFullName from the EnrolledStudent.raml file.

This system will not let me upload a tar file. I could email them.


#4

Feel free to upload your files to https://gist.github.com and share the links here.

Also, have you looked at some of the examples here: https://github.com/raml-org/raml-examples?


#5

Thank you for the pointers. I looked at the examples and was getting close on the library example. It looks like you should put libraries in the datatypes folder by the examples (shapes). Could this be correct??

Also, I tried to upload a zip and was not able to make that work. It said zip files are not supported (tried both upper and lower case.


#6

I got your gist and it looks fine.


#7

Yes, but it does not work. Some people are suggesting that what I must do is define a schema for each of the different responses for each resources. It seems like that really duplicates the examples you would create anyway. Do you have any suggestions about where I could talk to someone about this?

Thanks
/jon


#8

Sure. Feel free to join our Slack workspace. There are tool-specific channels. Feel free to reach-out to me there, my username is: jstoiko.