This repository was archived by the owner on Jun 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ GIT_REPO=gometal
10
10
PACKAGE_MAJOR =v1
11
11
12
12
SWAGGER =docker run --rm -v $(CURDIR ) :/local ${IMAGE}
13
+ GOLANGCI_LINT =golangci-lint
13
14
14
15
all : pull fetch patch gen
15
16
38
39
--git-repo-id ${GIT_REPO} \
39
40
-o /local/${PACKAGE_MAJOR} \
40
41
-i /local/${SPEC_PATCHED_FILE}
42
+
43
+ # https://github.com/OpenAPITools/openapi-generator/issues/741#issuecomment-569791780
44
+ remove-dupe-requests : # # Removes duplicate Request structs from the generated code
45
+ @for struct in $$(grep -h 'type .\{1,\} struct' $(PACKAGE_MAJOR ) /*.go | grep Request | sort | uniq -c | grep -v '^ 1' | awk '{print $$3}' ) ; do \
46
+ for f in $$ (/bin/ls $( PACKAGE_MAJOR) /* .go); do \
47
+ if grep -qF " type $$ {struct} struct" " $$ {f}" ; then \
48
+ if eval " test -z \$ ${$$ {struct} }" ; then \
49
+ echo " skipping first appearance of $$ {struct} in file $$ {f}" ; \
50
+ eval " export $$ {struct}=1" ; \
51
+ else \
52
+ echo " removing dupe $$ {struct} from file $$ {f}" ; \
53
+ tr ' \n' ' \r' < " $$ {f}" | sed ' s~// ' " $$ {struct}" ' .\{1,\}type ' " $$ {struct}" ' struct {[^}]\{1,\}}~~' | tr ' \r' ' \n' > " $$ {f}.tmp" ; \
54
+ mv -f " $$ {f}.tmp" " $$ {f}" ; \
55
+ fi ; \
56
+ fi \
57
+ done \
58
+ done
59
+ lint :
60
+ @$(GOLANGCI_LINT ) run -v --no-config --fast=false --fix --disable-all --enable goimports $(PACKAGE_MAJOR )
You can’t perform that action at this time.
0 commit comments