Code generation of responses

We are using codegen to generate the types used by our APIs, and we have a problem generating the responses of an API in a decent way.
As described here: , the responses classes are created with “cryptic” name rather than a real type.
I have tried two things:

  1. Using a Custom schema - To add a “title” field to the responses as suggested by the link - it works by editing the json, but to make it usable we need to a dd “title” field also to the UI.
  2. Using a reference - I have tried defining the responses as a model, and then to refer to it (so instead of referring to /responses it is mapped to /definitions) - but the UI does not show the models as option in the references dropdown in the UI. Please note that manually editing the json seems to pass without any error.
    What is the best way to handle it ?
    Please advise.

Can you send us an email at with a link to your project in Stoplight? We can take a closer look to see what might be going wrong here.

Email with sample project sent. Looking forward hearing from you.
Thanks !

@ross any news on this one?
Please note that when we manually edit the json to include reference to the /definitions - the code is generated correctly, but your UI (neither the editing, nor the “Read” mode) do not embrace it.

@agofer Sorry for the delay in following up here.

When you choose a “Reference” response type, this limits the available reference-able objects just to the shared responses. To use the model, you’ll need to select “Custom Schema” and then make the response object a reference to the model.

With regards to the “title” issue you referenced, you can edit the title of a model directly from the UI.

I’m not sure I understand why you are defining the model twice (once in the model, once in the shared response), but the better approach here would be to reference the model from the shared response, and then reference the shared response from the endpoint. I’ve updated the sample file in your project to reflect this change.

Let me know if anything is unclear.

@ross Thanks for the response.
The fact that I defined the model twice in this project was only for demonstration purposes.
That said, I believe you misinterpreted my question.

The problem I am trying to address is the ability to generate the code from the spec file. The problem is (as mentioned in the link on my original question) that the code generation using the standard Swagger codegen, does not give a useful name to the class it creates for a custom schema response.
To make sure it creates a useful name, there are two options:

  1. Add a “title” field on the schema - but you do not have such option on the UI (adding the field directly to the JSON works like charm)
  2. Refer to a model - this works perfect, but as you stated, you do not allow to refer to a model, but only to responses.
    The question is what is the best practice using stoplight. At the moment we are doing#1, but it means I have to manually edit the json and it is not really a good solution.
    Thanks !