Skip to content

ketzu/fizzbuzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FABI: A FizzBuzz JSON API

Do you think modulo is an unfair burden to your CPU? Do you prefer JSON APIs over complicated thinking? Were you asked to implement FizzBuzz?

This is the solution for you!

Usage

Call /exact.php?fb=15 or (with support for rewrite rules) use /15 to receive the FizzBuzz value of 15.

Call /to.php?fb=15 or (you know when) /to/15 to receive a JSON response of all values up to (including) 15.

Try it on fizzbuzz.ketzu.net!

Exact 15. Exact 100.

To 15. To 100.

Example Responses

Exact match 27:

"Fizz"

To 20:

[1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz",11,"Fizz",13,14,"FizzBuzz",16,17,"Fizz",19,"Buzz"]

Benchmark

We benchmarked FABI using the amazing api-benchmark node package!

You can find our benchmark script in the benchmark directory. And the (cleaned up for filesize) result, too.

The result for /to/100000 looks as follows:

Benchmark of /to/100000

The benchmark also contains a distribution of the response times:

Benchmark of /to/100000 as distribution

Docker

FABI is available as a docker container through docker-hub as ketzu/fabi.

OpenAPI and Swaggerhub

You can find the FABI example API on swaggerhub.

The created description, that can be amended easily for your own version is included in our openapi.yml.

openapi: 3.0.1
info:
  title: "FABI: A FizzBuzz API"
  description: Returns FizzBuzz Values in JSON Format.
  version: "1.0"
servers:
  - url: 'http://fizzbuzz.ketzu.net'
paths:
  /to/{targetNumber}:
    get:
      description: Get all FizzBuzz Values up to (including) targetNumber
      parameters:
        - in: path
          name: targetNumber
          schema:
            type: integer
          required: true
          description: Maximum Number to include in the reqeuested FizzBuzz list
      responses:
        '200':
          description: JSON Array of Numbers and Strings of either "Fizz", "Buzz" or "FizzBuzz"
          content:
            application/json:
              schema:
                type: array
                items: object
                properties: {}
      servers:
        - url: 'http://fizzbuzz.ketzu.net'
    servers:
      - url: 'http://fizzbuzz.ketzu.net'
  /{targetNumber}:
    get:
      description: Get the FizzBuzz Values of targetNumber
      parameters:
        - in: path
          name: targetNumber
          schema:
            type: integer
          required: true
          description: Number to determin the FizzBuzz value of
      responses:
        '200':
          description: Single Value String "Fizz", "Buzz", "FizzBuzz" or Number
          content:
            application/json:
              schema:
                type: object
                properties: {}
              examples:
                '0':
                  value: '"23"'
      servers:
        - url: 'http://fizzbuzz.ketzu.net'
    servers:
      - url: 'http://fizzbuzz.ketzu.net'

License

Feel free to use this project in any commercial application you might have for a free FizzBuzz API!

It's public under the MIT license.

About

FABI: A FizzBuzz JSON API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published