FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
stategraph/code/src/openapi_cli/openapi_cli.ml at main · stategraph/stategraph · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
stategraph
/
stategraph
Public
Notifications
You must be signed in to change notification settings
Fork
73
Star
1.3k
Code
Issues
107
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
stategraph
/
code
/
src
/
openapi_cli
/
openapi_cli.ml
Copy path
More file actions
More file actions
Latest commit
History
History
History
72 lines (61 loc) · 2.45 KB
Breadcrumbs
stategraph
/
code
/
src
/
openapi_cli
/
openapi_cli.ml
Copy path
File metadata and controls
72 lines (61 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module
Cmdline
=
struct
module
C
=
Cmdliner
let
output_name
=
let
doc
=
"
Root name for output files
"
in
C.Arg.
(required
&
opt (some
string
)
None
&
info [
"
n
"
;
"
name
"
]
~doc
)
let
output_dir
=
let
doc
=
"
Directory to write outputs to
"
in
C.Arg.
(required
&
opt (some
string
)
None
&
info [
"
output-dir
"
]
~doc
)
let
input_file
=
let
doc
=
"
Input file
"
in
C.Arg.
(required
&
opt (some
string
)
None
&
info [
"
i
"
;
"
input
"
]
~doc
)
let
non_strict_records
=
let
doc
=
"
Do not require records to be strict
"
in
C.Arg.
(value
&
flag
&
info [
"
non-strict-records
"
]
~doc
)
let
search_path
=
let
doc
=
"
Directory to search for files referenced by foreign $refs (e.g. \
\"
common.json#/definitions/Foo
\"
). May be passed multiple times; directories are searched \
in the order given.
"
in
C.Arg.
(value
&
opt_all dir
[]
&
info [
"
S
"
;
"
search-path
"
]
~doc
~docv:
"
DIR
"
)
let
file_link
=
let
link_conv
=
C.Arg.Conv.
make
~docv:
"
FILE=MODULE_BASE
"
~parser:
(
fun
s
->
match
CCString.Split.
left
~by:
"
=
"
s
with
|
Some
kv
->
Ok
kv
|
None
->
Error
"
Must be of form FILE=MODULE_BASE
"
)
~pp:
(
fun
fmt
(
file
,
module_base
) ->
Format.
fprintf fmt
"
%s=%s
"
file module_base)
()
in
let
doc
=
"
Reference a foreign schema file as an existing OCaml module instead of inlining it. Refs \
into FILE generate references to MODULE_BASE (e.g. \
\"
session-capabilities.json=Sgs_session_caps
\"
makes \
\"
session-capabilities.json#/definitions/Foo
\"
generate
\"
Sgs_session_caps_foo.t
\"
). May be \
passed multiple times.
"
in
C.Arg.
(value
&
opt_all link_conv
[]
&
info [
"
file-link
"
]
~doc
)
let
convert_cmd
f
=
let
doc
=
"
Convert to Ocaml
"
in
C.Cmd.
v
(
C.Cmd.
info
"
convert
"
~doc
)
C.Term.
(
const f
$
non_strict_records
$
input_file
$
output_name
$
output_dir
$
search_path
$
file_link)
let
default_cmd
=
C.Term.
(ret (const (
`Help
(
`Pager
,
None
))))
end
let
convert
non_strict_records
input_file
output_name
output_dir
search_path
file_link
=
let
strict_records
=
not
non_strict_records
in
Openapi_conv.
convert
~strict_records
~search_path
~file_link
~input_file
~output_name
~output_dir
let
cmds
=
Cmdline.
[ convert_cmd convert ]
let
()
=
let
info
=
Cmdliner.Cmd.
info
"
openapi_cli
"
in
exit
@@
Cmdliner.Cmd.
eval
@@
Cmdliner.Cmd.
group
~default:
Cmdline.
default_cmd info cmds
Back
|
FazBrowse Home
|
New Git URL