Skip to content

Instantly share code, notes, and snippets.

View ponelat's full-sized avatar

Josh Ponelat ponelat

View GitHub Profile
@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;
}
},
//...
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
authorizations: {
someName: function() {
// This function will get called /before/ each request
// ... UNLESS you have a 'security' tag in the swagger.json file, in which case you must add 'someName' to the list of auths.
console.log('explore the request object...',this) // Take a look in the console tab to see what's available.
this.headers['x-swagger'] = 'value'; // Example header
@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"
@ponelat
ponelat / settings.xml
Last active August 29, 2015 14:23
Error building maven project
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] XXXXXXXXXXX
[INFO] commons
[INFO] XXXXXXXX-api
[INFO] auth-api
[INFO]
[INFO] ------------------------------------------------------------------------
//...
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
authorizations: {
someName: new SwaggerClient.PasswordAuthorization("", "<username>", "<password>")
}
// ...........
@ponelat
ponelat / index.html
Created July 14, 2015 16:55
Inlined Spec file.
//...
window.swaggerUi = new SwaggerUi({
url: '',
spec: {
// The json contents of your spec file
}
dom_id: "swagger-ui-container",
// ...........
@ponelat
ponelat / index.html
Last active March 10, 2020 02:12
For having multiple specs in swagger-ui
<script>
// ...
var selectedUrl = "One";
var spec = {
"One": "/One.json",
"Two": "/Two.json"
}
function updateMultipleSpecs() {
swagger: '2.0'
info:
title: Uber API 2
description: Move your app forward with the Uber API
version: 1.0.0
host: api.uber.com
schemes:
- https
basePath: /v1
produces: