Skip to content

Instantly share code, notes, and snippets.

swagger: '2.0'
info:
version: 0.0.0
title: title
description: description
termsOfService: terms
license:
name: MIT
url: http://opensource.org/licenses/MIT
@fehguy
fehguy / pom.xml
Created January 30, 2017 21:48
sample pom.xml for generating code with swagger-codegen in-line
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.org</groupId>
<artifactId>my-project</artifactId>
<packaging>jar</packaging>
<name>my-project</name>
<version>1.0.0</version>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>

Supporting multipart/mixed Content-Type

To support multipart-mixed content types, we need to introduce another level of content in the requestBody definition. In the example below, we are defining a requestBody type of multipart/mixed and inside the content definition, we have multiple content types, one for each Content-Type.

This syntax only makes any sense under the multipart/mixed content type but may be help simplify multipart/form-data and possibly mulitpart/related and multipart/alternative, if we choose to support those.

myModels:
Pet:
type: object
properties:
id:
type: integer
format: int64
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>data-source-client</artifactId>
<packaging>jar</packaging>
<build>
@fehguy
fehguy / gist:00fa199128876a5f5afb
Created February 27, 2016 01:22
override example
package io.swagger.model.override;
import com.fasterxml.jackson.databind.JavaType;
import io.swagger.converter.ModelConverter;
import io.swagger.converter.ModelConverterContext;
import io.swagger.models.Model;
import io.swagger.models.properties.*;
import io.swagger.util.Json;
import java.lang.annotation.Annotation;
@fehguy
fehguy / gist:4d0850dcfb86a360bc47
Last active January 6, 2016 00:33
invalid-spec
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
////////
// HTTPS
if(config.PRODUCTION) {
app.use(function(req, res, next) {
if((!req.secure) && (req.get('X-Forwarded-Proto') !== 'https')) {
res.redirect('https://' + req.get('Host') + req.url);
}
else
next();
});
var swagger = {
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
<!DOCTYPE html>
<html>
<head>
<title>Swagger UI</title>
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>