I'm looking for a solution of converting swagger.json (generated by swagger2) to openapi3 json file in my CI/CD process (Git Actions).
I'm doing my job with Java, and I found some ways like:
Swagger inspector -> I guess it works in web env only.
SwaggerHub gradle plugin
Swagger codegen
but I have no experience of my task. which one is proper way to solve my problem? or is there any other way?
grateful for reading my question :)
Renew) I solved it completely, with using Swagger-parser
https://github.com/swagger-api/swagger-parser
example code is here:
#Test
public void parsingTest() throws Exception {
String outputDir = System.getProperty(YOUR_PATH_HERE);
SwaggerParseResult result = new OpenAPIParser().readLocation(YOUR_PATH_HERE, null, null);
OpenAPI api = result.getOpenAPI();
// POJO -> JSON
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.writeValue(new File(YOUR_PATH_HERE), api);
}
hope it makes helpful someone!
Related
I'm using Swashbuckle 5.6 which is using Swagger-UI 2.2. Unfortunately the dictionaries are not interpreted because Swagger-ui doesn't interpret the additionalProperties of a Map.
The result of swagger-ui is :
MyNamespace.Models.DictionaryErrorModel {
ValidationErrors (inline_model, optional, read only)
}
inline_model {} // The inlimodel is empty!!!
I want to customize swagger-ui in order to fix this bug. Could anyone help me?
Thanks.
I'm trying to write Dart code that will generate a rough equivalent of this:
var disposable = vscode['commands'].registerCommand(
'extension.sayHello',
function () {
vscode['window'].showInformationMessage('Hello World!');
}
);
context.subscriptions.push(disposable);
The variables vscode and context are both globals available in the JavaScript which is executing my Dart (which is being compiled to JS with the Dart Dev Compiler).
I'm happy for context/vscode to be completely untyped for now, but I'm struggling to bend the JS package to output code like this (eg. if I put #JS() on a stub vscode, I get dart.global.vscode).
You can use the base dart:js features
Note that context happens to be dart's name for the javascript context.
var disposable = context['vscode']['commands'].callMethod('registerCommand', [
'extension.sayHello',
() {
context['vscode']['window'].callMethod('showInformationMessage', ['Hello World!']);
}]);
);
context['context']['subscriptions'].callMethod('push', [disposable]);
Let me put together a quick example on github with package:js.
Edit: OK, here you go:
https://github.com/matanlurey/js-interop-examples
It took me a couple tries to the package:js syntax correct (we probably need more documentation here and examples), but I ended up creating a "fake" visual studio code API (vscode.js), and interoping with it fine.
Watch out that you need to wrap your functions with allowInterop if you expect your examples to work in Dartium.
I'm using Spray with the latest version of spray-swagger (0.5.1) and I can see my API documentation in swagger-ui just fine. But spray-swagger uses a hierarchical directory structure that starts at /api-docs...I want to use other swagger related tools and those tools seem to prefer a single swagger.json file.
Is there any tools to convert from /api-docs hierarchical directory structure to a single swagger.json file ?
You can use Swagger Converter. Here is an example provided in their page:
var convert = require('swagger-converter');
var resourceListing = require('/path/to/petstore/index.json');
var apiDeclarations = [
require('/path/to/petstore/pet.json'),
require('/path/to/petstore/user.json'),
require('/path/to/petstore/store.json')
];
var swagger2Document = convert(resourceListing, apiDeclarations);
console.log(swagger2Document);
Does Grails provide built-in or via a plugin support to consume (not to generate) XML based REST or SOAP web services ( esp. REST) ?
http://www.grails.org/plugin/rest
For SOAP based webservices, use WSClient. The plugin is a wrapper around GroovyWS. Under the hood, Apache CXF is working there.
In the past, I created a script (grails create-script) that used wsimport to create POJOs in the java src directory. Each time the script ran, it would delete the generated directory if it existed first, then generate new files.
I did this because the API that was being consumed was being developed and I wanted an easy way to consume the latest and greatest when new functionality was added.
In grails 3.x you can use the plugin in build.gradle
compile 'com.github.groovy-wslite:groovy-wslite:1.1.2'
Then add the import to your controller like in http://guides.grails.org/grails-soap/guide/index.html
import wslite.soap.*
import wslite.soap.SOAPClient
import wslite.soap.SOAPResponse
and use as the example available in https://github.com/jwagenleitner/groovy-wslite
def client = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')
def response = client.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMothersDay') {
body {
GetMothersDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
year(2011)
}
}
}
assert "2011-05-08T00:00:00" == response.GetMothersDayResponse.GetMothersDayResult.text()
assert 200 == response.httpResponse.statusCode
assert "ASP.NET" == response.httpResponse.headers['X-Powered-By']
render (response.GetMothersDayResponse.GetMothersDayResult.text())
using my windows service (target framework=.Net framework 4.0 client profile) I am trying to upload files to rackspace cloudfiles.
I found out some asp.net c# apis here https://github.com/rackspace/csharp-cloudfiles
but looks like they are not compatible with windows services.
any clues how to make this work together?
It's perfect library for work with rackspce. I am use it. And i am sure that it's not problem to use this library inside of windows service. But i think possible problems with .net framework client profile and com.mosso.cloudfiles.dll. But try first with client profile.
Also i use following code to upload files to Rackspace(Configuration it's my configuration class. Instead of 'Configuration.RackSpaceUserName' and 'Configuration.RackSpaceKey' use yous own creadentials):
private Connection CreateConnection()
{
var userCredentials = new UserCredentials(Configuration.RackSpaceUserName, Configuration.RackSpaceKey);
return new Connection(userCredentials);
}
public void SaveUniqueFile(string containerName, string fileName, Guid guid, byte[] buffer)
{
string extension = Path.GetExtension(fileName);
Connection connection = CreateConnection();
MemoryStream stream = new MemoryStream(buffer);
string uniqueFileName = String.Format("{0}{1}", guid, extension);
connection.PutStorageItem(containerName, stream, uniqueFileName);
}
Configuration something like this:
public class Configuration
{
public static string RackSpaceUserName = "userName";
public static string RackSpaceKey= "rackspaceKey";
}
I you don't want to use com.mosso.cloudfiles.dll very easy create you own driver for rackspace. Because actually for upload file to rackspace you just need send put request with 'X-Auth-Token' header. Also you can check request structure using plugin for firefox to view and upload files to Rackspace and firebug.
I have some example in C# using that same library here :
https://github.com/chmouel/upload-to-cf-cs
this is a pretty simple CLI but hopefully that should give an idea how to use it.
I've been around this for about one hour and weird things are happening into VS2010. Although I have referenced the dll and intellisense is working, cannot compile.
It looks like the referenced dll disappears. So, my recomendation in case you go into the same issue, use rack space for .NET 3.5: csharp-cloudfiles-DOTNETv3.5-bin-2.0.0.0.zip
Just be sure to change your project to the same framework version. It works really good.
For your reference, the downloads page is here: https://github.com/rackspace/csharp-cloudfiles/downloads