Convert Swagger JSON to RAML/YAML - json

How do I convert Swagger JSON to RAML/YAML and validate it? I am not looking for a programmatic way, just a one off conversion.

Here are the steps:
Export Swagger JSON into a file on your drive. This JSON should be published on your server at the following URI: /swagger/docs/v1
Go to http://editor.swagger.io/#/
On the top left corner, select File-> Import File... Point to the local Swagger JSON file you exported in step #1 to open in the Swagger Editor
Select Generate Client -> Swagger YAML option from the menu
It will generate the YAML that you can validate at http://www.yamllint.com/ site

To convert API spec between various formats (e.g. Swagger/OpenAPI, RAML, Postman, etc), you can use the following free and open source tools:
https://github.com/lucybot/api-spec-converter
https://github.com/stoplightio/api-spec-converter

Its actually pretty simple
Web version of swagger editor gives the flexibility to import your existing swagger file(JSON/YAML) and download the configuration file that is currently being shown. So just combine these two.
Note: Converting JSON to YAML exists, but not JSON to RAML
First import your swagger JSON at http://editor.swagger.io/#/ (File > Import File)
Once you see your configurations, just download the corresponding YAML version (File > Download YAML).
The YAML version of the JSON you just uploaded will be downloaded.

Conversion
If you are looking to convert from any version Swagger to RAML 0.8 then APITransformer.com can do it for you. We're almost done with RAML 1.0 export. Will release it in a week's time.
Validation
The converted description comes out of the same code-gen engine that APIMatic uses to validate an API description before generating SDKs/Client libraries. Therefore, the converted RAML will be validated by default.
API descriptions in a variety of formats can also be validated via APIMatic's CLI or APIMatic's API

While I wish there was a command line tool, this company has made a converter it seems:
https://apitransformer.com/

Related

How can I use any json or array or any js file in .testcaferc.json?

I have created one file .testcaferc.json that contains all configuration information like browser name, specs, timeouts etc. I want to fetch the configuration data from file so that I have to change the information at only one place
I want to store all these information in single file, I tried, js, json and array. But I can not import all above format files in my .testcaferc.json, when I press Alt+F8 I see the error "Expected a JSON object, array or literal"
Is there any way I can import json, array or js data in .testcaferc.json?
Thanks in advance!!
The JSON format doesn't support any import directives. The TestCafe configuration file (.testcaferc.json) is a simple JSON file. So, the TestCafe configuration file doesn't support such functionality.
To achieve your goal, you can transform the existing .testcaferc.json file before test running: load data from various sources and add/replace values for the appropriate data fields.
Also, there is a suggestion in the TestCafe GitHub repository, which will make your scenario easier to implement. Track it to be notified about its progress.

How can we read a json file only once for entire feature file in karate

I am calling multiple json and js files in my feature file in background, which is required for every scenarion in my feature file.
def test= read('classpath:testData/responseFiles/test.json')
problem is that, it is running/reading for each scenario. Is there something i can do, so that it read only once for feature file and can use for all scenarios. I am using 9.0.0 karate version
callonce is only working to call feature filen not json file
Read the JSON file in a called feature and then use callonce.

Polymer:how to handle csv file upload and convert to json and send to server

i want to handle a requirement in polymer webcomponents where user can upload csv file from ui and csv file can be parsed to json and sent to server ,i searched and found for vaadin upload,looked over the api but i am not sure how to receive the csv file and convert to json and sent to server,can anyone show a jsfiddle of vaadin upload or any other web component to handle this scenario?
First of all, I am wondering why you would not simply do the conversion on the server side.
In this case, you would be able to use the vaadin-upload directly indeed.
Here is a snippet that would upload all files to the example.com server, and only allow CSV files.
<vaadin-upload target="https://example.com/upload" method="POST" accept="text/csv">
</vaadin-upload>
There are plenty of resources on how to convert CSV files to JSON.
Here is a snippet
And here is a node library
If you really wanted to do the conversion client side, then I would suggest to create an element that would embed a vaadin-upload, and convert the Files array to Json before manually calling the uploadFiles method.

How to record jmeter script with fiddler [duplicate]

Has there any option(s) / work around to export fiddler trace files as .jmx files to be imported into JMeter?
Have a look at this:
http://www.perftesting.co.uk/creating-jmeter-test-plans-with-fiddler/2013/03/01/
Another option is to use HAR format (chrome or firefox+firebug+plugin) and use this:
https://blog.flood.io/convert-har-files-to-jmeter-test-plans/
Edit on 25 october 2020:
Since version 5.3 of JMeter, you can use menu Tools > Import from cURL which will allow you to import in JMeter a session exported as a set of cURL commands
See:
https://jmeter.apache.org/usermanual/curl.html#hints
Blazemeter have a free tool where you can convert exported HAR files from fiddler and save them as jmx files.
Worked very good for me.
I've created an extension which can transform HTTP request to any other text format as long as you can create a simple Mustache template for it. Recently I created a template to convert Fiddler Http request to JMeter project i.e. JMX file. It's a basic template but you can customize as per your needs.
https://github.com/hemantsharma-io/MockingBird#convert-a-get-http-request-to-jmx-ie-jmeter-for-perf-testing-in-fiddler

MarkLogic Java API batch upload files (.csv)

Im trying out the MarkLogic Java API and would want to bulk upload some files with the extension .csv
I'm not sure what to use, since the Java API only supports JSON, XML, and TXT files.
How do I batch upload files using the MarkLogic Java api? Do i convert everything to JSON?
Do i convert everything to JSON?
Yes, that is a common way to do it.
If you would like additional examples of how you can wrangle CSV with the Java Client API, check out OpenCSVBatcherExample and JacksonDatabindTest.testDatabindingThirdPartyPojoWithMixinAnnotations. The first demonstrates converting the csv to XML and using a custom REST extension. The second example (well, unit test...) demonstrates converting the csv to JSON and using the batch upload (Bulk Writes) capabilities Justin linked to.
If you have CSV files on your filesystem, I’d start with mlcp, as suggested above. It will handle all of the parsing and splitting into multiple transactions/batches for you. Take a look at the mlcp documentation for more details and some example configurations.
If you’d like more control over the parsing and splitting logic than mlcp gives you out-of-the-box or you’re getting CSV from some other source (i.e. not files on the filesystem), you can use the Java Client API. The Java Client API allows you to efficiently write batches using a WriteSet. Take a look at the “Bulk Writes” example.
According to your reply to Justin, you cannot use MLCP because it is command line and you need to integrate it into a web portal.
Well, MLCP is released as open cource software under the Apache2 licence. So if you are happy with this licence, then you have the source to integrate.
But what I see as your main problem statement is more specific:
How can I create miltiple XML OR JSON documents from a CSV file [allowing the use of the java API to then upload them as documents in MarkLogic]
With that specific problem statement:
1) have a look at SplitDelimitedTextReader.java from the mlcp source
2) try some java libraries for this purpose such as http://jsefa.sourceforge.net/quick-tutorial.html