Skip to content

Instantly share code, notes, and snippets.

View ponelat's full-sized avatar

Josh Ponelat ponelat

View GitHub Profile
@ponelat
ponelat / spec.json
Last active August 29, 2015 14:19
Simple,complete spec relating to swagger-ui#1133
{
"swagger": "2.0",
"host": "petstore.swagger.wordnik.com",
"info": {
"title": "Test Spec",
"version": "1.0.0"
},
"paths": {
"/road": {
"get": {
@ponelat
ponelat / external_and_rel_refs.json
Last active August 29, 2015 14:20
External $ref in path
{
"swagger": "2.0",
"basePath": "http://localhost:3000/s/",
"host": "petstore.swagger.wordnik.com",
"info": {
"title": "swagger-ui#1234",
"title": "Describe your issue here",
"version": "1.0.0"
},
"paths": {
{
"swagger": "2.0",
"host": "petstore.swagger.wordnik.com",
"info": {
"title": "swagger-ui#1234",
"title": "Describe your issue here",
"version": "1.0.0"
},
"paths": {
"/road": {
var client = require('swagger-client');
var swagger = new client({
url: 'http://petstore.swagger.io/v2/swagger.json',
success: function() {
swagger.apis.pet.getPetById({petId:10},function(pet){
console.log('pet', pet);
});
@ponelat
ponelat / send_a_cookie_swagger-ui_index.js
Last active August 29, 2015 14:22
Send Cookies with CORs (client side only)
@ponelat
ponelat / inline_spec_for_index.html.js
Last active August 29, 2015 14:22
Inline your swagger spec into swagger-ui's index.html file
// This goes in the dist/index.html file found in swagger-ui.
// Be careful that the file gets overwritten when you build swagger-ui
window.swaggerUi = new SwaggerUi({
url: url,
spec: {
// ...
// your spec here
// ....
},
@ponelat
ponelat / index.html.js
Last active August 29, 2015 14:22
Setup Auth in Swagger-UI
//...
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
@ponelat
ponelat / datafetcher.tag
Created June 15, 2015 09:27
jquery.getJson fail
this.fetch = function() {
url = this.url.value
$.getJSON(url).then(function(data){
opts.data.trigger('change', data);
}).fail(function() {
console.error('Failed to load/parse json data from', url);
console.error(arguments);
})
}
@ponelat
ponelat / dist_index.html
Created June 19, 2015 06:55
Send cookies back to server
// ...
window.swaggerUi = new SwaggerUi({
url: url,
useJQuery: true,
authorizations: {
makeCredentialed: function() {
this.xhrFields = {withCredentials: true}; // The important bit, along with useJQuery
return true;
}
},
@ponelat
ponelat / smoke_api.json
Created June 26, 2015 05:29
Smoke API for communication, during Ron's vay-cay
{
"swagger": "2.0",
"info": {
"title": "Smoke Signals v1",
"description": "Close to the metal communication with a Ron from middle-east",
"version": "1.0.0"
},
"host": "large-mountain-in.africa",
"schemes": [
"http"