forked from go-swagger/go-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed regression on name generation for "+" or "-" enum values
* fixes go-swagger#2050 * added support for "#" prefix handling values like 'go-swagger#235' * more unit testing on the pascalize function Signed-off-by: Frederic BIDON <[email protected]>
- Loading branch information
Showing
7 changed files
with
168 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gen-* | ||
!gen-fixtures.sh | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
swagger: "2.0" | ||
info: | ||
title: "enum with +,-" | ||
version: "0.0.1" | ||
description: "repro issue 2050" | ||
license: | ||
name: "Apache 2.0" | ||
url: "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
definitions: | ||
modelEnum: | ||
type: object | ||
properties: | ||
p0: | ||
type: string | ||
enum: | ||
- '+1' | ||
- '-1' | ||
- '0' | ||
p1: | ||
type: string | ||
enum: | ||
- '+' | ||
- '-' | ||
paths: | ||
/getRecords: | ||
get: | ||
operationId: getRecords | ||
parameters: | ||
- name: records | ||
in: body | ||
required: true | ||
schema: | ||
$ref: '#/definitions/modelEnum' | ||
responses: | ||
200: | ||
description: "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#! /bin/bash | ||
if [[ ${1} == "--clean" ]] ; then | ||
clean=1 | ||
fi | ||
continueOnError= | ||
# A small utility to build fixture servers | ||
# Fixtures with models only | ||
testcases="${testcases} fixture-2050.yaml" | ||
for opts in "" "--with-expand" ; do | ||
for testcase in ${testcases} ; do | ||
grep -q discriminator ${testcase} | ||
discriminated=$? | ||
if [[ ${discriminated} -eq 0 && ${opts} == "--with-expand" ]] ; then | ||
echo "Skipped ${testcase} with ${opts}: discriminator not supported with ${opts}" | ||
continue | ||
fi | ||
if [[ ${testcase} == "../1479/fixture-1479-part.yaml" && ${opts} == "--with-expand" ]] ; then | ||
echo "Skipped ${testcase} with ${opts}: known issue with enum in anonymous allOf not validated. See you next PR" | ||
continue | ||
fi | ||
|
||
spec=${testcase} | ||
testcase=`basename ${testcase}` | ||
if [[ -z ${opts} ]]; then | ||
target=./gen-${testcase%.*}-flatten | ||
else | ||
target=./gen-${testcase%.*}-expand | ||
fi | ||
serverName="codegensrv" | ||
rm -rf ${target} | ||
mkdir ${target} | ||
echo "Model generation for ${spec} with opts=${opts}" | ||
serverName="nrcodegen" | ||
swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 | ||
# 1>x.log 2>&1 | ||
# | ||
if [[ $? != 0 ]] ; then | ||
echo "Generation failed for ${spec}" | ||
if [[ ! -z ${continueOnError} ]] ; then | ||
failures="${failures} codegen:${spec}" | ||
continue | ||
else | ||
exit 1 | ||
fi | ||
fi | ||
echo "${spec}: Generation OK" | ||
if [[ ! -d ${target}/models ]] ; then | ||
echo "No model in this spec! Continue building server" | ||
fi | ||
if [[ -d ${target}/cmd/${serverName}"-server" ]] ; then | ||
(cd ${target}/cmd/${serverName}"-server"; go build) | ||
#(cd ${target}/models; go build) | ||
if [[ $? != 0 ]] ; then | ||
echo "Build failed for ${spec}" | ||
if [[ ! -z ${continueOnError} ]] ; then | ||
failures="${failures} build:${spec}" | ||
continue | ||
else | ||
exit 1 | ||
fi | ||
fi | ||
echo "${spec}: Build OK" | ||
if [[ -n ${clean} ]] ; then | ||
rm -rf ${target} | ||
fi | ||
fi | ||
done | ||
done | ||
if [[ ! -z ${failures} ]] ; then | ||
echo ${failures}|tr ' ' '\n' | ||
else | ||
echo "No failures" | ||
fi | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters