DEBIAN_FRONTEND=noninteractive apt-get -y install git make wget python \
python3 python3-all python3-pip python-pip \
debhelper tox python-setuptools \
- python3-setuptools build-essential dh-make && \
+ python3-setuptools build-essential dh-make \
+ openjdk-8-jdk maven && \
DEBIAN_FRONTEND=noninteractive pip3 install pip==9.0.3 && \
DEBIAN_FRONTEND=noninteractive pip3 install -U pyang pyangbind && \
DEBIAN_FRONTEND=noninteractive pip3 install -U stdeb && \
# NOTE: pyang and pyangbind are required for build
-.PHONY: all clean package trees deps yang-ietf
+.PHONY: all clean package trees deps yang-ietf openapi_schemas yang2swagger
PYANG:= pyang
PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \
'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS))
YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
+OPENAPI_SCHEMAS := osm.yaml
OUT_DIR := osm_im
TREES_DIR := osm_im_trees
PYANG_OPTIONS := -Werror
-all: $(PYTHON_MODELS) trees
+all: $(PYTHON_MODELS) trees openapi_schemas
$(MAKE) package
trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
+openapi_schemas: $(OPENAPI_SCHEMAS)
+
$(OUT_DIR):
$(Q)mkdir -p $(OUT_DIR)
$(Q)touch $(OUT_DIR)/__init__.py
$(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
$(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
+osm.yaml: $(OUT_DIR) yang-ietf yang2swagger
+ $(Q)echo generating $@
+ $(Q)java -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/*-SNAPSHOT/swagger-generator-cli-*-SNAPSHOT-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@
+
yang-ietf:
$(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O models/yang/ietf-yang-types.yang
$(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types%402013-07-15.yang -O models/yang/ietf-inet-types.yang
+yang2swagger:
+ $(Q)mkdir -p ${HOME}/.m2
+ $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml
+ git clone https://github.com/bartoszm/yang2swagger.git
+ mvn -f yang2swagger/pom.xml clean install
+
package:
tox -e build
tox -e build3
$(Q)cp -n ~/.m2/settings.xml{,.orig} ; wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
clean:
- $(Q)rm -rf dist osm_im.egg-info deb deb_dist *.gz $(OUT_DIR) $(TREES_DIR)
+ $(Q)rm -rf dist osm_im.egg-info deb deb_dist *.gz yang2swagger $(OUT_DIR) $(TREES_DIR)