Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ BUILD_IMG=beets-websearch-build
DOCKER_OPTS=--rm -u `id -u`:`id -g` \
-v "`pwd`:/work" -w /work \
--entrypoint sh $(BUILD_IMG) -c
OPENAPI_GENERATOR_VERSION=131fd518fbfe894cfa23619ede96adab707630d9 # v7.7.0+patch
OPENAPI_FILE=openapi.yaml
#OPENAPI_GENERATOR_VERSION=131fd518fbfe894cfa23619ede96adab707630d9 # v7.7.0+patch
OPENAPI_GENERATOR_VERSION=24b70a9200dc8532900a2896154081995c29fa91


.PHONY: wheel
wheel: clean python-container
docker run $(DOCKER_OPTS) 'python3 setup.py bdist_wheel'

.PHONY: validate-openapi
validate-openapi: OPENAPI_FILE=openapi.yaml
validate-openapi:
@echo Validating the OpenAPI spec at $(OPENAPI_FILE)
@docker run -t --rm --mount "type=bind,src=$(realpath $(OPENAPI_FILE)),dst=/openapi.yaml" \
Expand All @@ -31,7 +32,7 @@ validate-openapi:
generate: PKG=beetsplug.websearch
generate: .openapi-generator ## Generate server stub
rm -rf ./build/src-gen
docker run -ti --rm -v "`pwd`:/work" -w /work -u `id -u`:`id -g` openapitools/openapi-generator-cli:local-$(OPENAPI_GENERATOR_VERSION) generate -i ./openapi.yaml -g python-fastapi -o ./build/src-gen --package-name=$(PKG).gen -p sourceFolder= -p fastapiImplementationPackage=$(PKG).controller
docker --debug run -ti --rm -v "`pwd`:/work" -w /work -u `id -u`:`id -g` openapitools/openapi-generator-cli:local-$(OPENAPI_GENERATOR_VERSION) generate -i $(OPENAPI_FILE) -g python-fastapi -o ./build/src-gen --package-name=$(PKG).gen -p sourceFolder= -p fastapiImplementationPackage=$(PKG).controller
rm -rf ./beetsplug/websearch/gen
cp -r ./build/src-gen/beetsplug/websearch/gen ./beetsplug/websearch/gen

Expand Down Expand Up @@ -96,5 +97,5 @@ python-container:
docker build --force-rm -t openapitools/openapi-generator-cli:local-$(OPENAPI_GENERATOR_VERSION) build/openapi-generator

build/openapi-generator:
git clone -c advice.detachedHead=0 https://github.com/OpenAPITools/openapi-generator.git build/openapi-generator
git clone -c advice.detachedHead=0 https://github.com/mgoltzsche/openapi-generator.git build/openapi-generator

7 changes: 2 additions & 5 deletions beetsplug/websearch/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ async def list_tracks(
Track(
id="123",
title="Serpiente Dorada",
# TODO: make this work (generated code expects a string currently):
#additional_properties={
# "genre": "Dub",
# "bpm": "90",
#},
genre=str("Dub"),
bpm=str("90"),
),
],
)
Expand Down
4 changes: 2 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ components:
type: string
title:
type: string
additionalProperties:
type: string
additionalProperties:
type: string
required:
- id
- title
Expand Down