Where is the swagger json schema located? - swagger

The help for swashbuckle mentions that the ui for Swagger is driven by the generated json schema.
Where is this json file located?
I cannot find it in the folder for my asp.net project
When I actually run the application and navigate to http://localhost:51659/swagger/v1/swagger.json
then I see the json
Where is it on disk? Or is it only in memory?

There is no file generated, it is only on memory.
You might want to read a bit the code:
https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Swagger/SwaggerGenerator.cs
If you need a file you could create an IDocumentFilter to generate one. I have an example here generating a Yaml file:
https://github.com/heldersepu/Swagger-Net-Test/blob/master/Swagger_Test/App_Start/SwaggerConfig.cs#L378

Related

how to generate html from swagger yaml file [duplicate]

There are only ugly HTML pages as download (HTML, HTML2 and dynamic all ugly), but the site, eg. edited https://app.swaggerhub.com/apis/{user}/{project}/{version}
(and many others!) offers pretty HTML interface... How to download this pretty HTML?
Complete and autonomous HTML code (file or zip of files).
I have a good and valid swagger.yaml or swagger.json file of my API, so another solution is to run a open sourse (plug and play!) tool with my API-description file.
The pretty:
The ugly:
The "pretty interface" on your screenshot is Swagger UI. It's free and open-source. There's a demo at http://petstore.swagger.io, where you can load your own YAML/JSON files from an URL and see how they would be rendered.
To use Swagger UI locally:
Go to https://github.com/swagger-api/swagger-ui and download the repository as ZIP:
Edit the dist\index.html file and change the line
url: "http://petstore.swagger.io/v2/swagger.json",
to the URL of your Swagger .json or .yaml file, e.g.
url: "http://api.mysite.com/swagger.json",
(Optional) Add/change other configuration parameters in the SwaggerUIBundle initialization code in dist\index.html.
Open the dist\index.html file in your browser to preview your API docs.
Note: If the spec does not load or "try it out" does not work, you probably need to enable CORS on the your server. See https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/cors.md and https://enable-cors.org.
Upload the files from the dist folder somewhere to your server - and now you have pretty API docs too!
Alternatively, SwaggerHub (which you mentioned) provides cloud hosting for Swagger specs among other things, and has Swagger UI integrated. You can import your Swagger .json/.yaml files there and have your API docs hosted on SwaggerHub. A free plan is available.
Thanks to #tleyden at swagger-ui/issues for good clues!
Use the index and assets folder of this project, https://github.com/okfn-brasil/swagger-ui-html

Combine multiple swagger files

I was provided Swagger 2.0 json files for a RESTful API my project is using. The provider does not have SDK, so I'm using the Swagger files to generate a starting point to use for integrating with the service. It's split into 50+ files, grouped by collections of endpoints. How would I combine these into a single JSON or YAML file that conforms to the spec so I can generate SDK for all endpoints at once?
You can use a python script to read the contents of each json file and append them to one single json file. Swagger will read each field and render the ui to display all of the files on a single page.

Parse or convert .pb files under .sonar folder

I'm using sonarqube 5.6.5,everything works well . Now i need to parse the issues.PB file generated under .sonar/batch-report/ folder. i tried using jsonformat but it is not working.
They are "Protobuf" format, which is a format by google for serializing data. You can get started here or find for example a tutorial here on how to use it in Java.
What I don't understand is that your question has a tag "protobuf-net", which github page explains very well how to use it (in .NET).

Generate JSON file from Xcdatamodel

Is it possible to generate JSON file from xcdatamodel?
Here's how I imagine it would work: Given a xcdatamodel file, going through some program with some custom logic (will probably be written by me), will generate JSON file for me to use in third-party library. My question: Is this possible? Has anyone ever done it?
The content of xcdatamodel is a content file with xml data and as bin file (no extension) so now it is easy to parse xml to json.

Where to store XML files in Rails

I am writing a Ruby on Rails site which loads some data from an "local" XML file which I have. Where is a logical place in the rails directory structure to store this file?
Main question here is for what reason you have that XML files: configuration info or data storage. If first - then best place will be congif folder, otherwise - anywhere you like except public folder, you could even create xml folder inside app one.

Resources