Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Support for CSV and other formats #150

Closed
nightscape opened this issue Nov 4, 2014 · 3 comments
Closed

Support for CSV and other formats #150

nightscape opened this issue Nov 4, 2014 · 3 comments

Comments

@nightscape
Copy link

Is there support for formats other than JSON?
We're using CSV as exchange format in some places and it would be great to be able to use that in pacto as well.
If CSV support does not exist yet, what would need to be done to add it? Can this be done by someone who's not very familiar with pacto yet?

Thanks!
Martin

@maxlinc
Copy link
Collaborator

maxlinc commented Nov 11, 2014

Pacto is moving towards using Swagger as the way to describe contracts. Swagger does support multiple formats, and there's people figuring out the best ways to use it for JSON & XML. I think as long as we can come up with a good way to model the CSV it could be done.

It would be pretty easy to specify and test that it should be a CSV file. It's just a matter of telling Swagger that the service produces "text/csv" (see the operation and mime type sections of the swagger specification).

Testing that it is a proper CSV - one with the field names you expect and the right types of data (e.g. a field named "zipcode" that contains 5 digit numbers) is a little trickier. I'm not aware of a widely used schema language for CSVs like there is for JSON (json-schema) or XML (xsd or relaxng). There is a CSVSchema, but I'd never heard of it before just now, and I think it might actually be easier to use a format similar to how Swagger describes headers or parameters than to use CSVSchema. That would probably require some slight changes to the Swagger spec though - right now it only allows one body parameter.

I think a good next step is if you send an example CSV and contract (preferably as Swagger 2.0 rather than Pacto's "legacy" contract format) and a short description of what parts of the CSV you'd like Pacto to validate.

@nightscape
Copy link
Author

Hi maxlinc,

I did some research on Swagger and CSV but haven't found a lot. Unfortunately I got pulled into other stuff and haven't had time to advance with pacto yet.
Shall I close this issue for the time being and reopen when I have time to work on this?

Thanks a lot for your help!
Martin

@maxlinc
Copy link
Collaborator

maxlinc commented Dec 18, 2014

Closing, but created #154 for the more general problem.

@maxlinc maxlinc closed this as completed Dec 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants