Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen doesn't use "example" for response body #2387

Open
pcads opened this issue Mar 15, 2016 · 5 comments
Open

Codegen doesn't use "example" for response body #2387

pcads opened this issue Mar 15, 2016 · 5 comments

Comments

@pcads
Copy link

pcads commented Mar 15, 2016

Not sure if this is by design or bug.
I have example for every object under definitions section. When I use codegen to generate a nodejs server, I am hoping at least the response body for GET should use the example data, but it doesn't.

Example data shows up under "Response Class", but when I click "Try it out!", in stead of example data, I get generic json object generated by Codegen using the schema. Like {"userName": "aeiou"}

Do I miss anything? Thanks

@wing328
Copy link
Contributor

wing328 commented Mar 16, 2016

@pcads I don't think the nodejs server stub generator supports the feature you mentioned and we welcome contribution to make the improvement.

The msutache template for nodejs is a good starting point:

https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/nodejs

@pcads
Copy link
Author

pcads commented Mar 16, 2016

I am not familiar with mustache. I will take a look and hopefully I could do something. Thanks

@wing328 wing328 modified the milestones: v2.2.0, v2.1.6 Mar 19, 2016
@wing328
Copy link
Contributor

wing328 commented Mar 21, 2016

My apologies. In the nodejs template, I did find the use of {{examples}} mustache tag:

service.mustache:  {{#examples}}examples['{{contentType}}'] = {{{example}}};
service.mustache:  {{/examples}}

Can you try starting the nodejs server with the following command instead?

NODE_ENV=development node index

@pcads
Copy link
Author

pcads commented Mar 21, 2016

I tried with NODE_ENV=development node index, still doesn't work.

@djskinner
Copy link

Yeah I don't think using the example data is in the node template. I was using it earlier and the controllers serve up dummy data that contains the likes of {"userName": "aeiou"}

@wing328 wing328 modified the milestones: v2.2.0, v2.3.0 Jul 7, 2016
@wing328 wing328 modified the milestones: v2.2.1, v2.2.2 Aug 8, 2016
@wing328 wing328 modified the milestones: Future, v2.2.2 Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants