This repository has been archived by the owner on Jul 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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":[]}}}} | ||
``` |