Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Created April 17, 2020 15:15
Show Gist options
  • Save sonOfRa/0b4ec77b29b7c0e1f628529ff0128ff9 to your computer and use it in GitHub Desktop.
Save sonOfRa/0b4ec77b29b7c0e1f628529ff0128ff9 to your computer and use it in GitHub Desktop.
openapi: 3.0.3
info:
title: Cocktail and ingredient API
version: 0.0.1
servers:
- url: http://localhost:8080/
description: Local development server
tags:
- name: 'ingredients'
description: 'Ingredient Operations'
- name: 'cocktails'
description: 'Cocktail Operations'
paths:
/ingredients:
get:
operationId: getIngredients
summary: Get all ingredients
tags:
- ingredients
responses:
200:
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/LocalizedIngredient'
post:
operationId: createIngredient
summary: Create a new ingredient in the database
tags:
- ingredients
requestBody:
description: The ingredient to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateIngredient'
responses:
200:
description: Retrieve the created ingredient
content:
application/json:
schema:
$ref: '#/components/schemas/Ingredient'
400:
description: Invalid ingredient data
/ingredients/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
example: 10
get:
operationId: getIngredientById
summary: Get a single ingredient by its ID
tags:
- ingredients
responses:
200:
description: Found ingredient
content:
application/json:
schema:
$ref: '#/components/schemas/Ingredient'
404:
description: Ingredient not found
post:
operationId: updateIngredient
summary: Update the ingredient with the specified ID
tags:
- ingredients
requestBody:
description: The ingredient data to update with
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateIngredient'
responses:
200:
description: Updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Ingredient'
400:
description: Invalid ingredient data
404:
description: Ingredient not found
/ingredients/types:
get:
operationId: getIngredientTypes
summary: Get a list of ingredient types on the server
tags:
- ingredients
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/LocalizedIngredientType'
/ingredients/types/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
example: 5
get:
operationId: getIngredientTypeById
summary: Get an ingredient type by its ID
tags:
- ingredients
responses:
200:
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/IngredientType'
404:
description: Ingredient Type not found
components:
schemas:
LocalizedIngredientType:
description: An ingredient type in a single language
type: object
required:
- type
- id
- language
properties:
id:
type: integer
format: int64
example: 15
language:
type: string
example: de
type:
type: string
example: Starker Alkohol
LocalizedIngredient:
description: An ingredient in a single language
IngredientType:
description: An ingredient type, with all languages
properties:
id:
type: integer
format: int64
example: 15
names:
$ref: '#/components/schemas/TranslatedString'
Ingredient:
description: An ingredient, with all languages
CreateIngredient:
description: An ingredient for creation on the server
TranslatedString:
description: A translated string
type: object
required:
- id
properties:
id:
type: integer
format: int64
additionalProperties:
type: string
minItems: 1
example:
de: Limettensaft
en: Lime juice
package de.slevermann.cocktails.models;
import java.util.Objects;
import io.swagger.annotations.ApiModel;
import java.util.HashMap;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* A translated string
*/
@ApiModel(description = "A translated string")
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-17T17:11:32.034+02:00[Europe/Berlin]")
public class TranslatedString extends HashMap<String, String> {
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TranslatedString {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment