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

feat: add workdir arg to openapi command #450

Merged
merged 2 commits into from
Feb 25, 2022
Merged

feat: add workdir arg to openapi command #450

merged 2 commits into from
Feb 25, 2022

Conversation

jdecool
Copy link
Contributor

@jdecool jdecool commented Feb 24, 2022

🧰 Changes

We use a monorepo structure to manage our projects and our OpenAPI specification contains relative references to external models.

So when running rdme on our repository, we need to specify the current working directory to handle those relative paths.

This PR adds an optional workdir parameter to the openapi command.

🧬 QA & Testing

To test it, you have to run the openapi command using the --workdir=path.
So all file should be relative to the specified path.

@jdecool
Copy link
Contributor Author

jdecool commented Feb 24, 2022

@kanadgupta
Copy link
Member

Thanks for the PR @jdecool! Could you add a test case for this? Along with an OpenAPI definition example that uses relative references? You can see a similar example here:

it('should bundle and upload the expected content', async () => {
let requestBody = null;
const mock = getApiNock()
.get('/api/v1/api-specification')
.basicAuth({ user: key })
.reply(200, [])
.get(`/api/v1/version/${version}`)
.basicAuth({ user: key })
.reply(200, { version: '1.0.0' })
.post('/api/v1/api-specification', body => {
requestBody = body.substring(body.indexOf('{'), body.lastIndexOf('}') + 1);
requestBody = JSON.parse(requestBody);
return body.match('form-data; name="spec"');
})
.basicAuth({ user: key })
.reply(201, { _id: 1 }, { location: exampleRefLocation });
await expect(openapi.run({ spec: './__tests__/__fixtures__/ref-oas/petstore.json', key, version })).resolves.toBe(
successfulUpload
);
expect(console.info).toHaveBeenCalledTimes(0);
expect(requestBody).toMatchSnapshot();
return mock.done();
});

@jdecool
Copy link
Contributor Author

jdecool commented Feb 24, 2022

Thanks for your answer @kanadgupta and for your explanation.

I've just updated the PR with a test case.

@kanadgupta
Copy link
Member

Thanks for the test @jdecool! Could you also add this parameter to the validate command?

@kanadgupta kanadgupta added the enhancement New feature or request label Feb 24, 2022
@jdecool
Copy link
Contributor Author

jdecool commented Feb 24, 2022

Could you also add this parameter to the validate command?

Sure.

Done in the last commit

@kanadgupta kanadgupta added this to the v6.5 milestone Feb 25, 2022
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jdecool!

@kanadgupta kanadgupta requested a review from erunion February 25, 2022 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants