Receiving warning: oasOpParams expects a resolved object
See original GitHub issueI’m submitting a bug report
What is the current behavior?
I am currently migrating my API specification and running into this warning:
oasOpParams expects a resolved object, but none was provided. Results may not be correct.
oasPathParam expects a resolved object, but none was provided. Results may not be correct.
There are no $ref
mentions in my spec, so I am confused as to why I am getting this error. The code is as follows.
What is the expected behavior?
For this not to error
Please tell us about your environment:
- Version:
@stoplight/spectral": "^1.0.1"
- Framework: Node v11.7.0
- Language: Node v11.7.0
Other information
My code:
// Load Spectral and its OAS3 validations
const { Spectral } = require('@stoplight/spectral')
const { oas3Functions, oas3Rules } = require('@stoplight/spectral/rulesets/oas3')
// Find all OpenAPI files
const fs = require('fs')
const glob = require('glob')
const lint = async () => {
const fileNames = await new Promise((resolve, reject) => {
glob('./v2.0/*.openapi.json', {}, (error, match) => {
if (error) { reject(error) }
else { resolve(match) }
})
})
// Initialize Spectral
const spectral = new Spectral()
spectral.addFunctions(oas3Functions())
spectral.addRules(oas3Rules())
fileNames.forEach(fileName => {
let specification = JSON.parse(fs.readFileSync(fileName))
const results = spectral.run(specification)
// console.dir(results)
})
}
lint()
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
node.js - Expect and should use the Promise object instead of ...
I found the mistake. The problem is that the correct syntax is not .should.to.be but has to be .should.eventually.be.
Read more >The spectral from stoplightio - Giter VIP
oasOpParams expects a resolved object, but none was provided. Results may not be correct. oasPathParam expects a resolved object, but none was provided....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @cbetta - great question, and this is something that we could certainly be more clear about (will open a separate PR for readme).
Certain rules (like those param rules you mentioned above) need both the resolved and unresolved document in order to function. Since you don’t have any $refs in your document, you should be able to supply it as the resolved version like so:
You can find the run signature here: https://github.com/stoplightio/spectral/blob/next/src/spectral.ts#L21.
I’m now wondering if we shouldn’t just default resolvedTarget to the passed in document if resolvedTarget is not explicitly set.
Let me know if the above works for you for now!
@cbetta Glad to hear the improvements worked.