Skip to content

Instantly share code, notes, and snippets.

View mathis-m's full-sized avatar
💻
coding

Mahtis Michel mathis-m

💻
coding
  • Avanade
  • Stuttgart, Germany
View GitHub Profile
@mathis-m
mathis-m / string_date-time.yaml
Created February 12, 2021 08:07
string date-time
type: string
format: date-time
@mathis-m
mathis-m / date-picker.js
Last active February 12, 2021 08:22
date-picker plugin
import React from "react";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
const JsonSchema_string_date = (props) => {
const dateNumber = Date.parse(props.value);
const date = dateNumber
? new Date(dateNumber)
: new Date();
openapi: 3.0.0
info:
version: "{version}"
title: Sample API with anyOf and oneOf
paths:
/test:
get:
parameters:
- in: query
name: afterDate
@mathis-m
mathis-m / DatePickerApp.js
Last active April 5, 2021 13:55
Example Integration
import SwaggerUI from "swagger-ui-react"
import React from "react";
import "swagger-ui-react/swagger-ui.css"
const App = () =>
<SwaggerUI
url="https://gist.githubusercontent.com/mathis-m/fcd7022b7f7db2e14112a87ab7c3b637/raw/13bc4f249391f88c1cdde1b51cc2d791e7518d6b/date-picker.yaml"
plugins={[ DateTimeSwaggerPlugin ]}
/>
@mathis-m
mathis-m / logout-plugin.js
Created February 14, 2021 03:05
Custom Logout Plugin
const MyLogoutPlugin = () => ({
statePlugins: {
auth: {
wrapActions: {
logout: (internalLogoutAction) => (keys) => {
// here, you can run the logout request.
console.log("Logout from following securities:", keys)
return internalLogoutAction(keys) // don't forget! otherwise, Swagger UI won't logout
}
}
@mathis-m
mathis-m / swagger-ui-usability.md
Created February 18, 2021 18:04
swagger-ui usability review

Analysis

Personas

When it comes to usability one of the main key points that should be taken into consideration is knowing the different personas of your product.

I can identify at least 5 different groups that will use swagger-ui within a products lifecycle:

  • API developer
  • Client developer
  • Consultant introducing the API to client developer
  • Tester
openapi: 3.0.0
info:
title: asd
version: "123"
paths:
/:
post:
requestBody:
content:
application/json:
openapi: 3.0.2
info:
title: FastAPI
version: 0.1.0
paths:
/:
post:
summary: Root
operationId: root__post
requestBody:
openapi: 3.0.0
info:
title: test
version: 0.0.0
paths:
/something/{id}:
parameters:
- in: path
name: id
required: true
openapi: 3.0.0
info:
title: test
version: 0.0.0
paths:
/something/{id}:
parameters:
- in: path
name: id
required: true