-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C++][RESTSDK] support enums #2749
Conversation
Sync with upstream
Sync with upstream
Sync with upstream
The generated code does not compile in Linux. ---
# This is a sample Swagger spec, describing a simple API as a starting point.
swagger: "2.0"
info:
description: Template Description
version: 1.0.0
title: Testspec
host: 0.0.0.0:8080
basePath: /api
schemes:
- http
paths:
/v1.0/testintenum:
get:
description: ""
operationId: testintenum
responses:
200:
description: "Successful response"
schema:
$ref: '#/definitions/intEnum'
400:
description: "The request was not successfully executed."
/v1.0/teststringenum:
get:
description: ""
operationId: teststringenum
responses:
200:
description: "Successful response"
schema:
$ref: '#/definitions/stringEnum'
400:
description: "The request was not successfully executed."
/v1.0/testintenum1:
get:
description: ""
operationId: testintenum1
responses:
200:
description: "Successful response"
schema:
type: object
additionalProperties:
$ref: '#/definitions/intEnum'
400:
description: "The request was not successfully executed."
/v1.0/teststringenum1:
get:
description: ""
operationId: teststringenum1
responses:
200:
description: "Successful response"
schema:
type: array
items:
$ref: '#/definitions/stringEnum'
400:
description: "The request was not successfully executed."
/v1.0/test:
get:
description: ""
operationId: test
responses:
200:
description: "Successful response"
schema:
$ref: '#/definitions/enumeration'
400:
description: "The request was not successfully executed."
definitions:
stringEnum:
description: "string enum"
enum:
- abc
- def
- ghi
type: string
intEnum:
description: "integer enum"
enum:
- 1
- 2
- 3
type: integer
enumeration:
type: object
description: "string enum"
properties:
enint:
$ref: '#/definitions/intEnum'
enstr:
$ref: '#/definitions/stringEnum'
enarr:
type: array
items:
$ref: '#/definitions/stringEnum'
enaobj:
type: object
additionalProperties:
$ref: '#/definitions/intEnum' |
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-header.mustache
Outdated
Show resolved
Hide resolved
enum e{{classname}} | ||
{ | ||
{{#allowableValues}} | ||
{{#values}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wont it be better to add {{#enumDescription}}
?
@stkrwork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. maybe for the future it would be a good idea to extend samples for generators that support enums, to also generate samples including enums. @etherealjoy @wing328
PR checklist
./bin/
to lsupdate Petstore sample so that CIs can verify the change. (For instance, only need to run
./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,. Default:3.4.x
,4.0.x
master
.Description of the PR
This is a fix for #1316 (Enumerations not generated). It closely follows the recommendations provided by the poster with a couple minor differences.
Fixes #1316
@ravinikam @stkrwork @fvarose @etherealjoy @MartinDelille