Hello,

   I've ran into a kind of funky problem where I have two operation objects 
with similar but not identical schemas. The get operation has a schema 
reference that points to a json file containing a standardized mason 
wrapper with an items collection in it. This items collection is a list of 
individual objects (in this case invoices). Then we also have a put 
operation under the same path where we can update a single object and it's 
schema points to just the individual objects schema file.  The problem I am 
seeing is that when Swagger UI attempts to resolve the json references it 
gets one reference right but then the later reference throws it off where 
it looks like it is trying to use the wrong location as it's baseDoc path. 
 Also it appears SwaggerCLI has no problem with the $refs as they are 
currently and prior to referencing the individual instance of the schema 
directly from the put operation all the references would resolve fine. 
 I've tested this in Swagger UI 3.0.21.


*swagger.json  Path object*
"ws/v1/customers/invoices/{invoiceId}": {
"parameters": [
{
"name": "invoiceId",
"in": "path",
"description": "The Invoice id.",
"required": true,
"type": "string"
}
],
"get": {
"summary": "Returns the specified Invoice.",
"tags": ["invoices"],
"responses": {
"200": {
"description": "The invoice requested in our standard collection object",
"schema": {
"$ref": "../collections/invoices.json"
}
}
}
},
"put": {
"summary": "Updates the specified Invoice.",
"tags": ["invoices"],
"parameters": [
{
"name": "Invoice",
"in": "body",
"description": "The updated Invoice.",
"required": true,
"schema": {
"$ref": "../schemas/invoice.json"
}
}
],
"responses": {
"200": {
"description": "A paged collection of Invoices",
"schema": {
"$ref": "../schemas/invoice.json"
}
}
}
}
}


*/collections/invoices.json*
{
"type": "object",
"properties":{
"@namespace": {
"type": "object",
"properties": {
"uvrel": {
"type": "string"
}
}
},
"items": {
"type": "array",
"items":{
"$ref":"../schemas/invoice.json"
}
},
"@controls": {
"type":"object",
"properties": {
"describedby": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"self": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
}
}
}


*/schemas/invoice.json*
{
"title": "customer-invoice",
"properties": {
"totalAmount": {
"description": "Invoice Total Amount",
"type": "number"
},
"currency": {
"$ref": "microformats/currency.json"
},
...
}
"type": "object",
"description": "Invoice header resource"
}


*/schemas/microformats/**currency.json*
{
    "properties": {
        "description": {
            "description": "Name of currency",
            "type": "string"
        },
        "code": {
            "pattern": "[A-Z]{3}",
            "description": "Currency code",
            "type": "string"
        }
    },
    "description": "Currency object",
    "type": "object"
}


*Swagger UI throws errors for any microformats we use within our schemas as 
follows*
Resolver error at 
paths./ws/v1/customers/invoices/{invoice}.put.responses.200.schema.properties.items.items.properties.currency.$refCould
 
not resolve reference because of: Not Found


*Javascript Console contains*
n {message: "Could not resolve reference because of: Not Found", 
originalError: Error: Not Found
    at http://development:8080/system/api/swagger-ui-bundle.js:52:174646
…, pointer: "", $ref: "microformats/currency.json", baseDoc: 
"/system/api/ref/collections/invoices.json"…}$ref: 
"microformats/currency.json"baseDoc: 
"/system/api/ref/collections/invoices.json"fullPath: Array(12)level: 
"error"line: 40message: "Could not resolve reference because of: Not 
Found"originalError: Error: Not Found
    at http://development:8080/system/api/swagger-ui-bundle.js:52:174646
    at <anonymous>path: 
"paths./ws/v1/customers/invoices/{invoice}.put.responses.200.schema.properties.items.items.properties.currency.$ref"pointer:
 
""source: "resolver"type: "thrown"stack: "JSONRefError↵    at o 
(http://development:8080/system/api/swagger-ui-bundle.js:52:197768)↵    at 
http://development:8080/system/api/swagger-ui-bundle.js:52:200499↵    at 
<anonymous>"__proto__: Error
    at r (http://development:8080/system/api/swagger-ui-bundle.js:52:178095)
    at Object.<anonymous> 
(http://development:8080/system/api/swagger-ui-bundle.js:52:199857)
    at t (http://development:8080/system/api/swagger-ui-bundle.js:52:167480)
    at Object.e.exports.Object.defineProperty.value 
(http://development:8080/system/api/swagger-ui-bundle.js:52:187615)
    at t (http://development:8080/system/api/swagger-ui-bundle.js:52:167480)
    at Object.e.exports.Object.defineProperty.value 
(http://development:8080/system/api/swagger-ui-bundle.js:52:187214)
    at t (http://development:8080/system/api/swagger-ui-bundle.js:52:167480)
    at Object.e.exports.Object.defineProperty.value 
(http://development:8080/system/api/swagger-ui-bundle.js:52:178871)
    at t (http://development:8080/system/api/swagger-ui-bundle.js:52:167480)
    at Object.<anonymous> 
(http://development:8080/system/api/swagger-ui-bundle.js:52:201598)
(anonymous) @ swagger-ui-bundle.js:12
(anonymous) @ swagger-ui-bundle.js:12
swagger-ui-bundle.js:12 n {message: "Could not resolve reference because 
of: Not Found", originalError: Error: Not Found
    at http://development:8080/system/api/swagger-ui-bundle.js:52:174646
…, pointer: "", $ref: "microformats/currency.json", baseDoc: 
"/system/api/ref/collections/invoices.json"…}        *<-- This bit in 
particular looks like part of the problem since it is ending up with the 
wrong baseDoc path.*
(anonymous) @ swagger-ui-bundle.js:12
(anonymous) @ swagger-ui-bundle.js:12

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to swagger-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to