Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
Add output formats
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Nov 12, 2023
1 parent ad9128e commit 8eeb2fe
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions docs/geting_further/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
layout: page
title: Output Formats
permalink: /getting-further/output/
parent: Getting Further
nav_order: 2
---

Noir supports various output formats such as JSON, YAML, among others.

## Basic
```bash
noir -b sources

# GET /secret.html
# GET /posts
# GET /posts/1
# POST /posts {"id":"","title":"","context":""} X-API-KEY:
# PUT /posts/1 {"id":"","title":"","context":""} X-API-KEY:
# DELETE /posts/1
```

## JSON
```bash
noir -b sources -f json

# [{"url":"/secret.html","method":"GET","params":[],"headers":[],"protocol":"http"},{"url":"/posts","method":"GET","params":[],"headers":[],"protocol":"http"},{"url":"/posts/1","method":"GET","params":[],"headers":[],"protocol":"http"},{"url":"/posts","method":"POST","params":[{"name":"id","value":"","param_type":"json"},{"name":"title","value":"","param_type":"json"},{"name":"context","value":"","param_type":"json"},{"name":"X-API-KEY","value":"","param_type":"header"}],"headers":[],"protocol":"http"},{"url":"/posts/1","method":"PUT","params":[{"name":"id","value":"","param_type":"json"},{"name":"title","value":"","param_type":"json"},{"name":"context","value":"","param_type":"json"},{"name":"X-API-KEY","value":"","param_type":"header"}],"headers":[],"protocol":"http"},{"url":"/posts/1","method":"DELETE","params":[],"headers":[],"protocol":"http"}]
```

## YAML
```bash
noir -b sources -f json

# ---
# - url: /secret.html
# method: GET
# params: []
# headers: []
# protocol: http
# - url: /posts
# method: GET
# params: &1 []
# headers: []
# protocol: http
# ....
```

## Curl

```bash
noir -b sources -f curl

# curl -i -X GET /secret.html
# curl -i -X GET /posts
# curl -i -X GET /posts/1
# curl -i -X POST /posts -d "{"id":"","title":"","context":""}" -H "Content-Type:application/json" -H "X-API-KEY: "
# curl -i -X PUT /posts/1 -d "{"id":"","title":"","context":""}" -H "Content-Type:application/json" -H "X-API-KEY: "
# curl -i -X DELETE /posts/1
```

## HTTpie
```bash
noir -b sources -f httpie

# http GET /secret.html
# http GET /posts
# http GET /posts/1
# http POST /posts {"id":"","title":"","context":""} "Content-Type:application/json" "X-API-KEY: "
# http PUT /posts/1 {"id":"","title":"","context":""} "Content-Type:application/json" "X-API-KEY: "
# http DELETE /posts/1
```

## Markdown Table
```bash
noir -b . -f markdown-table

# | Endpoint | Protocol | Params |
# | -------- | -------- | ------ |
# | GET /secret.html | http | |
# | GET /posts | http | |
# | GET /posts/1 | http | |
# | POST /posts | http | `id (json)` `title (json)` `context (json)` `X-API-KEY (header)` |
# | PUT /posts/1 | http | `id (json)` `title (json)` `context (json)` `X-API-KEY (header)` |
# | DELETE /posts/1 | http | |
```

## OAS2/OAS3

```bash
noir -b . -f oas2
noir -b . -f oas3

# OAS2
# {"swagger":"2.0","info":{"title":"Generated by Noir","version":""},"basePath":"","paths":{"/secret.html":{"get":{"responses":{"200":{"description":"Successful response"}},"parameters":[]}},"/posts":{"post":{"responses":{"200":{"description":"Successful response"}},"parameters":[{"name":"id","in":"form"},{"name":"title","in":"form"},{"name":"context","in":"form"},{"name":"X-API-KEY","in":"header"}]}},"/posts/1":{"delete":{"responses":{"200":{"description":"Successful response"}},"parameters":[]}}}}

# OAS3
# {"openapi":"3.0.0","info":{"title":"Generated by Noir","version":""},"paths":{"/secret.html":{"get":{"responses":{"200":{"description":"Successful response"}},"parameters":[]}},"/posts":{"post":{"responses":{"200":{"description":"Successful response"}},"parameters":[{"name":"id","in":"form"},{"name":"title","in":"form"},{"name":"context","in":"form"},{"name":"X-API-KEY","in":"header"}]}},"/posts/1":{"delete":{"responses":{"200":{"description":"Successful response"}},"parameters":[]}}}}
```

0 comments on commit 8eeb2fe

Please sign in to comment.