Providing Valid Model IDs


Hello my API Designing Brothers & Sisters!

I woke up in a frenzied sweat last night and started writing a spec for a declarative API documentation & testing generator, only to come to my senses this morning and actually google it and find you wonderful people!

It looks like you have almost EVERY feature I was hoping for, except since mine was implemented with code, it had a feature that I don’t know how you’d implement with RAML, curious how you go about solving:

I’m procedurally populating my database, and would probably re-populate between destructive REST tests (maybe this is more of a SoapUI question):

If an endpoint only returns a valid response when given a valid model ID, how do I tell RAML, and in turn SoapUI, how to retrieve valid Model IDs?

I hope this is a no-brainer for you, some really great looking work here!

-Dan Finlay


That went longer than I expected without a response given the activity of this community. I’m inclined to think this problem hasn’t been solved yet, and I’ll need to provide my own RAML-testing solution if I want to do what I described.


Hi Dan,

Sorry for letting this hang on the vine - I’ve been traveling and without reliable internet since the middle of next week.

I’m not sure I quite get the use-case you are describing here. Are you looking for an endpoint that will only return a successful response when given a valid model ID, and will return a failure when the model ID is invalid, or an endpoint that won’t respond at all if the model ID is invalid? When you say “valid model ID” do you me “a model ID that exists” or “a model ID that is of the right format”?

It might help me understand more precisely if you described the ideal experience (even in a user-story format) that you are looking for, with a bit more specifics.

Thanks - hopefully I’ll be able to help!


I’m starting to think my desire here is beyond the scope of RAML itself, and is more suited for a RAML interpreting test generator.

In such a test generator, I would want each end point and parameter to be queried within and beyond their specified limits.

Let’s say my application has users, and my users have comments, and the API allows you to limit the number of comments, but at a maximum of 50. My test generator may pick an arbitrarily large number to test that limit, say, /users/123/comments?limit=500.

To test a claimed maximum for the limit parameter, I need to be querying against an actual user with some large number of actual comments. This requires foreknowledge of an actual user id and in this case even a number of comments to pre-populate that model with.

I’m coming to think this really doesn’t belong in RAML at all, since these are model-type behaviors, but instead, would be features of a RAML-interpreting test generator I’m considering. In that case, the test generator would need to have “hooks” to populate and retrieve valid testable IDs from, and from there should be able to manipulate the data and test the described API to a very thorough degree.