Skip to content

Commit

Permalink
deref example
Browse files Browse the repository at this point in the history
  • Loading branch information
podhmo committed Nov 26, 2016
1 parent 2f8adfb commit dff71c9
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,31 @@ example4:
cat .tmp/03* | gsed 's/^/ /g' >> example4.rst
rm -r .tmp

.PHONY: example example4
example5:
rm -rf .tmp; mkdir -p .tmp
tree examples/deref > .tmp/00structure.txt
for i in `find examples/deref/ -name "*.yaml" -type f`; do cat $$i > .tmp/01`echo $$i | tr '/' '__'`; done
for i in `find examples/deref/ -name "*.py" -type f`; do cat $$i > .tmp/02`echo $$i | tr '/' '__'`; done
(cd examples/deref; swagger-bundler bundle main.yaml) > .tmp/03generated.yaml
rm -f example5.rst; touch example5.rst
echo "# structure" >> example5.rst
echo "\n.. code-block:: bash" >> example5.rst
echo "" >> example5.rst
echo "$ tree" | gsed 's/^/ /g' >> example5.rst
cat .tmp/00* | gsed 's/^/ /g' >> example5.rst
echo "$ swagger-bundler bundle main.yaml > generated.yaml" | gsed 's/^/ /g' >> example5.rst
echo "\n## swagger-bundler.ini(config file)" >> example5.rst
echo "\n.. code-block::" >> example5.rst
echo "" >> example5.rst
cat examples/deref/swagger-bundler.ini | gsed 's/^/ /g' >> example5.rst
for i in `ls .tmp/02* | grep -v generated.py`; do echo "\n" >> example5.rst; echo `echo $${i} | gsed 's@^.tmp/02examples_@@g; s@__*@/@g;'` >> example5.rst; echo "\n.. code-block:: python\n" >> example5.rst; cat $${i} | gsed 's/^/ /g' >> example5.rst; done
echo "\n" >> example5.rst
for i in `ls .tmp/01* | grep -v generated.yaml`; do echo "\n" >> example5.rst; echo `echo $${i} | gsed 's@^.tmp/01examples_@@g; s@__*@/@g;'` >> example5.rst; echo "\n.. code-block:: yaml\n" >> example5.rst; cat $${i} | gsed 's/^/ /g' >> example5.rst; done
echo "\n" >> example5.rst
echo "## generated.yaml" >> example5.rst
echo "\n.. code-block:: yaml\n" >> example5.rst
cat .tmp/03* | gsed 's/^/ /g' >> example5.rst
rm -r .tmp

.PHONY: example
.PHONY: watch updatespec test regenerate
134 changes: 134 additions & 0 deletions example5.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# structure

.. code-block:: bash
tree
examples/deref
├── color
│   ├── cmyk.yaml
│   └── rgb.yaml
├── group
│   └── group.yaml
├── main.yaml
├── swagger-bundler.ini
└── x.yaml
2 directories, 6 files
swagger-bundler bundle main.yaml > generated.yaml
## swagger-bundler.ini(config file)

.. code-block::
[DEFAULT]
[special_marker]
# todo: gentle description.
namespace = x-bundler-namespace
compose = x-bundler-compose
concat = x-bundler-concat
exposed = x-bundler-exposed
[postscript_hook]
# lambda ctx, data, *args, **kwargs: do_something()
## examples:
# swagger_bundler.postscript:echo
# or
# a/b/c/d.py:function_name
compose =
bundle =
add_namespace =
validate =
load = swagger_bundler.postscript:deref_support_for_extra_file
deref/color/cmyk.yaml

.. code-block:: yaml
definitions:
color:
type: string
enum:
- C
- M
- Y
- K
deref/color/rgb.yaml

.. code-block:: yaml
definitions:
color:
type: string
enum:
- r
- g
- b
deref/group/group.yaml

.. code-block:: yaml
definitions:
group:
type: string
enum:
- A
- B
- C
color:
$ref: "../color/rgb.yaml#/definitions/color"
deref/main.yaml

.. code-block:: yaml
x-bundler-compose:
- x.yaml as X
definitions:
foo:
$ref: "./group/group.yaml#/definitions/group"
color:
$ref: "group/group.yaml#/definitions/color"
deref/x.yaml

.. code-block:: yaml
definitions:
color:
$ref: color/cmyk.yaml#/definitions/color
## generated.yaml

.. code-block:: yaml
definitions:
XColor:
type: string
enum:
- C
- M
- Y
- K
foo:
type: string
enum:
- A
- B
- C
color:
type: string
enum:
- r
- g
- b
8 changes: 8 additions & 0 deletions examples/deref/color/cmyk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
definitions:
color:
type: string
enum:
- C
- M
- Y
- K
7 changes: 7 additions & 0 deletions examples/deref/color/rgb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
definitions:
color:
type: string
enum:
- r
- g
- b
9 changes: 9 additions & 0 deletions examples/deref/group/group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
definitions:
group:
type: string
enum:
- A
- B
- C
color:
$ref: "../color/rgb.yaml#/definitions/color"
8 changes: 8 additions & 0 deletions examples/deref/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
x-bundler-compose:
- x.yaml as X

definitions:
foo:
$ref: "./group/group.yaml#/definitions/group"
color:
$ref: "group/group.yaml#/definitions/color"
20 changes: 20 additions & 0 deletions examples/deref/swagger-bundler.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[DEFAULT]

[special_marker]
# todo: gentle description.
namespace = x-bundler-namespace
compose = x-bundler-compose
concat = x-bundler-concat
exposed = x-bundler-exposed

[postscript_hook]
# lambda ctx, data, *args, **kwargs: do_something()
## examples:
# swagger_bundler.postscript:echo
# or
# a/b/c/d.py:function_name
compose =
bundle =
add_namespace =
validate =
load = swagger_bundler.postscript:deref_support_for_extra_file
3 changes: 3 additions & 0 deletions examples/deref/x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
definitions:
color:
$ref: color/cmyk.yaml#/definitions/color

0 comments on commit dff71c9

Please sign in to comment.