Skip to content

Instantly share code, notes, and snippets.

@typingincolor
Last active December 18, 2015 22:49
Show Gist options
  • Save typingincolor/5857219 to your computer and use it in GitHub Desktop.
Save typingincolor/5857219 to your computer and use it in GitHub Desktop.
When using swagger-ui, working.js spec displays correctly but not-working.js does not. The only difference between them is that working has a dummy api method (see difference). If you look at the /stores/{storeName}/products/{id} GET. The working version shows Pro, and BestUse models in the schema. For the non-working version they don't.
{
path: "/stores/dummy",
description: "Store operations",
operations: [{
parameters: [],
httpMethod: "GET",
notes: "Dummy method to get around Swagger problem",
errorResponses: [],
nickname: "dummy",
summary: "Dummy Method",
description: "Store operations",
path: "/stores/dummy",
method: "GET",
params: [],
responseClass: "Dummy"
}]
}
{
apiVersion: "0.1",
swaggerVersion: "1.1",
basePath: "http://localhost:5000",
resourcePath: "/stores",
apis: [{
path: "/stores",
description: "Store operations",
operations: [{
parameters: [],
httpMethod: "GET",
notes: "Returns a list of the available stores",
errorResponses: [],
nickname: "getStores",
summary: "Get list of stores",
description: "Store operations",
path: "/stores",
method: "GET",
params: [],
responseClass: "Stores"
}]
}, {
path: "/stores/{storeName}",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
httpMethod: "GET",
notes: "Returns store details based on a store name",
errorResponses: [{
code: 400,
reason: "invalid storeName"
}, {
code: 404,
reason: "Store not found"
}],
nickname: "getStore",
summary: "Find store by storeName",
description: "Store operations",
path: "/stores/{storeName}",
method: "GET",
params: [{
name: "storeName",
description: "Store to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
responseClass: "Store"
}]
}, {
path: "/stores/{storeName}/products",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
httpMethod: "GET",
notes: "Search for product",
errorResponses: [{
code: 404,
reason: "products not found"
}],
nickname: "searchForProduct",
summary: "Product search",
description: "Store operations",
path: "/stores/{storeName}/products",
method: "GET",
params: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
responseClass: "ProductList"
}]
}, {
path: "/stores/{storeName}/products/{id}",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "id",
description: "Product to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
httpMethod: "GET",
notes: "Returns a product based on it's ID",
errorResponses: [{
code: 404,
reason: "product not found"
}],
nickname: "getProduct",
summary: "Find product by id",
description: "Store operations",
path: "/stores/{storeName}/products/{id}",
method: "GET",
params: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "id",
description: "Product to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
responseClass: "Product"
}]
}, {
path: "/stores/{storeName}/login",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "Credentials",
description: "Credentials to be authenticated",
dataType: "Credentials",
required: true,
allowMultiple: false,
paramType: "body"
}],
httpMethod: "POST",
notes: "Validates a user against Websphere Commerce",
errorResponses: [{
code: 401,
reason: "unauthorized - user credentials have expired"
}, {
code: 403,
reason: "forbidden"
}, {
code: 400,
reason: "invalid credentials"
}],
nickname: "login",
summary: "Validate User",
description: "Store operations",
path: "/stores/{storeName}/login",
method: "POST",
params: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "Credentials",
description: "Credentials to be authenticated",
dataType: "Credentials",
required: true,
allowMultiple: false,
paramType: "body"
}],
responseClass: "AuthenticationResult"
}]
}],
models: {
Stores: {
properties: {
stores: {
type: "List",
items: {
$ref: "string",
description: "store URI"
}
}
}
},
Store: {
storeName: "Store",
properties: {
productsUri: {
type: "string"
},
genericUserUri: {
type: "string"
},
userUri: {
type: "string"
},
loginUri: {
type: "string"
},
espotsUri: {
type: "string"
},
postcodeLookupUri: {
type: "string"
},
storeImage: {
type: "Media"
}
}
},
ProductList: {
properties: {
productListItems: {
type: "List",
description: "list of matching products",
items: {
$ref: "ProductDetails"
}
}
}
},
Product: {
properties: {
productDetails: {
required: true,
type: "ProductDetails"
},
kiddicareSpecificProductDetails: {
type: "KiddicareSpecificProductDetails"
},
wineSpecificProductDetails: {
type: "WineSpecificProductDetails"
},
stockLevel: {
type: "StockLevel"
},
crossSellInformation: {
type: "CrossSellInformation"
},
productItems: {
type: "List",
items: {
$ref: "ProductDetails"
}
},
reviews: {
type: "ReviewList"
},
promoCode: {
type: "string"
}
}
},
Credentials: {
properties: {
username: {
type: "string"
},
password: {
type: "string"
}
}
},
AuthenticationResult: {
properties: {
authentication: {
type: "Authentication"
}
}
},
Media: {
properties: {
mediaType: {
required: true,
type: "string",
allowableValues: {
valueType: "LIST",
values: ["image", "video", "gallery"]
}
},
size: {
type: "string"
},
location: {
required: true,
type: "string"
}
}
},
ProductDetails: {
properties: {
catEntryId: {
type: "string"
},
partNumber: {
type: "string"
},
name: {
type: "string"
},
shortDescription: {
type: "string"
},
longDescription: {
type: "string"
},
rating: {
type: "number"
},
reviewCount: {
type: "int"
},
listPrice: {
type: "number"
},
cannotBeSoldInQuantityOne: {
type: "boolean"
},
itemCatEntryId: {
type: "string"
},
itemPartNumber: {
type: "string"
},
catEntryType: {
type: "string"
},
productType: {
type: "string"
},
media: {
type: "array",
description: "list of images",
items: {
$ref: "Media"
}
}
}
},
KiddicareSpecificProductDetails: {
properties: {
arrivalDate: {
type: "Date"
},
availabilityDate: {
type: "Date"
},
bestUse: {
type: "List",
items: {
$ref: "BestUse"
}
},
pros: {
type: "List",
items: {
$ref: "Pro"
}
},
comment: {
type: "string"
},
coughMixture: {
type: "boolean"
},
deposit: {
type: "boolean"
},
directDelivery: {
type: "boolean"
},
feverMedicine: {
type: "boolean"
},
freeDelivery: {
type: "boolean"
},
tripTrapp: {
type: "boolean"
}
}
},
WineSpecificProductDetails: {
properties: {
tasteProfile: {
type: "int"
},
abv: {
type: "number"
},
region: {
type: "string"
},
vintage: {
type: "int"
},
closure: {
type: "string"
},
alcoholUnits: {
type: "number"
},
bottleSize: {
type: "string"
},
halfCasePrice: {
type: "number"
},
fullCasePrice: {
type: "number"
}
}
},
StockLevel: {
properties: {
buyable: {
type: "boolean"
},
availableQuantity: {
type: "int"
},
markForDeletion: {
type: "boolean"
},
published: {
type: "boolean"
},
threshold: {
type: "int"
}
}
},
ReviewList: {
properties: {
reviewList: {
type: "List",
items: {
$ref: "Review"
}
},
totalReviews: {
type: "int"
}
}
},
Authentication: {
properties: {
userId: {
type: "string"
},
userActivityId: {
type: "string"
},
authetnicationId: {
type: "string"
},
userUri: {
type: "string"
}
}
}
}
}
{
apiVersion: "0.1",
swaggerVersion: "1.1",
basePath: "http://localhost:5000",
resourcePath: "/stores",
apis: [{
path: "/stores",
description: "Store operations",
operations: [{
parameters: [],
httpMethod: "GET",
notes: "Returns a list of the available stores",
errorResponses: [],
nickname: "getStores",
summary: "Get list of stores",
description: "Store operations",
path: "/stores",
method: "GET",
params: [],
responseClass: "Stores"
}]
}, {
path: "/stores/dummy",
description: "Store operations",
operations: [{
parameters: [],
httpMethod: "GET",
notes: "Dummy method to get around Swagger problem",
errorResponses: [],
nickname: "dummy",
summary: "Dummy Method",
description: "Store operations",
path: "/stores/dummy",
method: "GET",
params: [],
responseClass: "Dummy"
}]
}, {
path: "/stores/{storeName}",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
httpMethod: "GET",
notes: "Returns store details based on a store name",
errorResponses: [{
code: 400,
reason: "invalid storeName"
}, {
code: 404,
reason: "Store not found"
}],
nickname: "getStore",
summary: "Find store by storeName",
description: "Store operations",
path: "/stores/{storeName}",
method: "GET",
params: [{
name: "storeName",
description: "Store to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
responseClass: "Store"
}]
}, {
path: "/stores/{storeName}/products",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
httpMethod: "GET",
notes: "Search for product",
errorResponses: [{
code: 404,
reason: "products not found"
}],
nickname: "searchForProduct",
summary: "Product search",
description: "Store operations",
path: "/stores/{storeName}/products",
method: "GET",
params: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
responseClass: "ProductList"
}]
}, {
path: "/stores/{storeName}/products/{id}",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "id",
description: "Product to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
httpMethod: "GET",
notes: "Returns a product based on it's ID",
errorResponses: [{
code: 404,
reason: "product not found"
}],
nickname: "getProduct",
summary: "Find product by id",
description: "Store operations",
path: "/stores/{storeName}/products/{id}",
method: "GET",
params: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "id",
description: "Product to be fetched",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}],
responseClass: "Product"
}]
}, {
path: "/stores/{storeName}/login",
description: "Store operations",
operations: [{
parameters: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "Credentials",
description: "Credentials to be authenticated",
dataType: "Credentials",
required: true,
allowMultiple: false,
paramType: "body"
}],
httpMethod: "POST",
notes: "Validates a user against Websphere Commerce",
errorResponses: [{
code: 401,
reason: "unauthorized - user credentials have expired"
}, {
code: 403,
reason: "forbidden"
}, {
code: 400,
reason: "invalid credentials"
}],
nickname: "login",
summary: "Validate User",
description: "Store operations",
path: "/stores/{storeName}/login",
method: "POST",
params: [{
name: "storeName",
description: "Store to search",
dataType: "string",
required: true,
allowMultiple: false,
paramType: "path"
}, {
name: "Credentials",
description: "Credentials to be authenticated",
dataType: "Credentials",
required: true,
allowMultiple: false,
paramType: "body"
}],
responseClass: "AuthenticationResult"
}]
}],
models: {
Stores: {
properties: {
stores: {
type: "List",
items: {
$ref: "string",
description: "store URI"
}
}
}
},
Dummy: {
properties: {
bestUse: {
type: "BestUse"
},
pro: {
type: "Pro"
},
review: {
type: "Review"
},
stockLevel: {
type: "StockLevel"
}
}
},
Store: {
storeName: "Store",
properties: {
productsUri: {
type: "string"
},
genericUserUri: {
type: "string"
},
userUri: {
type: "string"
},
loginUri: {
type: "string"
},
espotsUri: {
type: "string"
},
postcodeLookupUri: {
type: "string"
},
storeImage: {
type: "Media"
}
}
},
ProductList: {
properties: {
productListItems: {
type: "List",
description: "list of matching products",
items: {
$ref: "ProductDetails"
}
}
}
},
Product: {
properties: {
productDetails: {
required: true,
type: "ProductDetails"
},
kiddicareSpecificProductDetails: {
type: "KiddicareSpecificProductDetails"
},
wineSpecificProductDetails: {
type: "WineSpecificProductDetails"
},
stockLevel: {
type: "StockLevel"
},
crossSellInformation: {
type: "CrossSellInformation"
},
productItems: {
type: "List",
items: {
$ref: "ProductDetails"
}
},
reviews: {
type: "ReviewList"
},
promoCode: {
type: "string"
}
}
},
Credentials: {
properties: {
username: {
type: "string"
},
password: {
type: "string"
}
}
},
AuthenticationResult: {
properties: {
authentication: {
type: "Authentication"
}
}
},
BestUse: {
properties: {
bestUse: {
type: "string"
},
count: {
type: "int"
}
}
},
Pro: {
properties: {
pro: {
type: "string"
},
count: {
type: "int"
}
}
},
Review: {
properties: {
comment: {
type: "string"
},
rating: {
type: "number"
},
name: {
type: "string"
},
date: {
type: "Date"
},
reviewTitle: {
type: "string"
}
}
},
StockLevel: {
properties: {
buyable: {
type: "boolean"
},
availableQuantity: {
type: "int"
},
markForDeletion: {
type: "boolean"
},
published: {
type: "boolean"
},
threshold: {
type: "int"
}
}
},
Media: {
properties: {
mediaType: {
required: true,
type: "string",
allowableValues: {
valueType: "LIST",
values: ["image", "video", "gallery"]
}
},
size: {
type: "string"
},
location: {
required: true,
type: "string"
}
}
},
ProductDetails: {
properties: {
catEntryId: {
type: "string"
},
partNumber: {
type: "string"
},
name: {
type: "string"
},
shortDescription: {
type: "string"
},
longDescription: {
type: "string"
},
rating: {
type: "number"
},
reviewCount: {
type: "int"
},
listPrice: {
type: "number"
},
cannotBeSoldInQuantityOne: {
type: "boolean"
},
itemCatEntryId: {
type: "string"
},
itemPartNumber: {
type: "string"
},
catEntryType: {
type: "string"
},
productType: {
type: "string"
},
media: {
type: "array",
description: "list of images",
items: {
$ref: "Media"
}
}
}
},
KiddicareSpecificProductDetails: {
properties: {
arrivalDate: {
type: "Date"
},
availabilityDate: {
type: "Date"
},
bestUse: {
type: "List",
items: {
$ref: "BestUse"
}
},
pros: {
type: "List",
items: {
$ref: "Pro"
}
},
comment: {
type: "string"
},
coughMixture: {
type: "boolean"
},
deposit: {
type: "boolean"
},
directDelivery: {
type: "boolean"
},
feverMedicine: {
type: "boolean"
},
freeDelivery: {
type: "boolean"
},
tripTrapp: {
type: "boolean"
}
}
},
WineSpecificProductDetails: {
properties: {
tasteProfile: {
type: "int"
},
abv: {
type: "number"
},
region: {
type: "string"
},
vintage: {
type: "int"
},
closure: {
type: "string"
},
alcoholUnits: {
type: "number"
},
bottleSize: {
type: "string"
},
halfCasePrice: {
type: "number"
},
fullCasePrice: {
type: "number"
}
}
},
ReviewList: {
properties: {
reviewList: {
type: "List",
items: {
$ref: "Review"
}
},
totalReviews: {
type: "int"
}
}
},
Authentication: {
properties: {
userId: {
type: "string"
},
userActivityId: {
type: "string"
},
authetnicationId: {
type: "string"
},
userUri: {
type: "string"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment