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

'enum' doesn't work #625

Closed
Suicide40 opened this issue Sep 29, 2014 · 11 comments
Closed

'enum' doesn't work #625

Suicide40 opened this issue Sep 29, 2014 · 11 comments

Comments

@Suicide40
Copy link

.....
'enum' => [
0 => 'Both',
1 => 'Physical',
2 => 'Electronic',
],
'dataType' => 'integer',
.....
that is work !
BUT
....
'enum' => [
1 => 'Physical',
2 => 'Electronic',
0 => 'Both',
],
'dataType' => 'integer',
.....
DOESN'T WORK

@webron
Copy link
Contributor

webron commented Oct 2, 2014

That really depends on the Swagger specification file you have. Not really sure what language is that and which library you use to produce your swagger specification.

Can you provide the json output you get for both options?

@Suicide40
Copy link
Author

{"resourcePath":"/products","basePath":"http://cardwiser.local/api/client/web","apis":[{"path":"/api/getCategories","description":"Categories","operations":[{"parameters":[],"summary":"Categories","httpMethod":"POST","nickname":"getCategories"}]},{"path":"/api/getBrands","description":"Brands","operations":[{"parameters":[{"name":"page","description":"page","dataType":"integer","allowMultiple":false,"paramType":"form"},{"name":"char","description":"char","dataType":"string","allowMultiple":false,"paramType":"form"},{"name":"price_filter","description":"price_filter","dataType":"integer","allowMultiple":false,"paramType":"form"},{"name":"cat_id","description":"cat_id","dataType":"integer","allowMultiple":false,"paramType":"form"},{"name":"pro_type","description":"pro_type","required":false,"enum":["Both","Physical","Electronic"],"dataType":"integer","allowMultiple":false,"defaultValue":"Physical","paramType":"form","type":"string"}],"summary":"Brands","httpMethod":"POST","nickname":"getBrands"}]},{"path":"/api/getAllBrands","description":"All Brands","operations":[{"parameters":[],"summary":"All Brands","httpMethod":"POST","nickname":"getAllBrands"}]},{"path":"/api/rate_brand","description":"Add/Edit Rating of Brand","operations":[{"parameters":[{"name":"mem_id","description":"mem_id","dataType":"integer","required":true,"allowMultiple":false,"paramType":"form"},{"name":"brand_id","description":"brand_id","dataType":"integer","required":true,"allowMultiple":false,"paramType":"form"},{"name":"rate","description":"rate","dataType":"integer","required":true,"allowMultiple":false,"paramType":"form"}],"summary":"Add/Edit Rating of Brand","httpMethod":"POST","nickname":"rate_brand"}]}],"apiVersion":"1.0.0","swaggerVersion":"1.0"}

@Suicide40
Copy link
Author

{"resourcePath":"/products","basePath":"http://cardwiser.local/api/client/web","apis":[{"path":"/api/getCategories","description":"Categories","operations":[{"parameters":[],"summary":"Categories","httpMethod":"POST","nickname":"getCategories"}]},{"path":"/api/getBrands","description":"Brands","operations":[{"parameters":[{"name":"page","description":"page","dataType":"integer","allowMultiple":false,"paramType":"form"},{"name":"char","description":"char","dataType":"string","allowMultiple":false,"paramType":"form"},{"name":"price_filter","description":"price_filter","dataType":"integer","allowMultiple":false,"paramType":"form"},{"name":"cat_id","description":"cat_id","dataType":"integer","allowMultiple":false,"paramType":"form"},{"name":"pro_type","description":"pro_type","required":false,"enum":{"1":"Physical","2":"Electronic","0":"Both"},"dataType":"integer","allowMultiple":false,"defaultValue":"Physical","paramType":"form","type":"string"}],"summary":"Brands","httpMethod":"POST","nickname":"getBrands"}]},{"path":"/api/getAllBrands","description":"All Brands","operations":[{"parameters":[],"summary":"All Brands","httpMethod":"POST","nickname":"getAllBrands"}]},{"path":"/api/rate_brand","description":"Add/Edit Rating of Brand","operations":[{"parameters":[{"name":"mem_id","description":"mem_id","dataType":"integer","required":true,"allowMultiple":false,"paramType":"form"},{"name":"brand_id","description":"brand_id","dataType":"integer","required":true,"allowMultiple":false,"paramType":"form"},{"name":"rate","description":"rate","dataType":"integer","required":true,"allowMultiple":false,"paramType":"form"}],"summary":"Add/Edit Rating of Brand","httpMethod":"POST","nickname":"rate_brand"}]}],"apiVersion":"1.0.0","swaggerVersion":"1.0"}

@webron
Copy link
Contributor

webron commented Oct 3, 2014

Oh wow, that's a very old version of Swagger Spec. Which library do you use to produce that? I don't think the UI supports it at all anymore.

@Suicide40
Copy link
Author

/ swagger-ui.js
// version 2.0.21
.....

@webron
Copy link
Contributor

webron commented Oct 3, 2014

No, I mean which library do you use to produce the json output you pasted above?

@Suicide40
Copy link
Author

sorry, did you mean that ?
// swagger.js
// version 2.0.36

in index.html swagger get php file with array of options. That's all.

@webron
Copy link
Contributor

webron commented Oct 3, 2014

No, that's the version of swagger-ui/swagger-js.

So you're using php? Do you use swagger-php? Any other php library to generate the swagger documentation?

@Suicide40
Copy link
Author

...
$(function () {
window.swaggerUi = new SwaggerUi({
url: "json/client/resources.php",
dom_id: "swagger-ui-container",
....

resources.php contains the clean json_encoded array.

..
echo json_encode([
'apis' => [
[
......

@webron
Copy link
Contributor

webron commented Oct 3, 2014

I'm sorry, @Suicide40, but I really don't understand your set up. I don't know php at all, and I don't understand how your json is being generated.

@Suicide40
Copy link
Author

ok, I will try to make it on other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants