-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Make moduleObject.mustache confirms to JSONEncodable. #11202
Changes from all commits
09dacc7
fc433db
aae8e6d
1c06b4d
7836e27
e55c757
ebd7d01
d855a09
4929d5b
f4da07a
7c1a144
8b1529f
6ec206b
5a1661b
7acc1fb
51fe33f
672df35
8962b8b
235b824
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} { | ||
{{/objcCompatible}}{{#objcCompatible}}@objc {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable { | ||
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable, JSONEncodable{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} { | ||
{{/objcCompatible}}{{#objcCompatible}}@objc {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable, JSONEncodable { | ||
{{/objcCompatible}} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please also add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{{#allVars}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: test | ||
version: '1.0' | ||
servers: | ||
- url: 'http://localhost:3000' | ||
paths: | ||
/postModel: | ||
post: | ||
summary: Create New User | ||
operationId: post-user | ||
responses: | ||
'200': | ||
description: User Created | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/User' | ||
examples: {} | ||
'400': | ||
description: Missing Required Information | ||
description: Create a new user. | ||
requestBody: | ||
content: | ||
multipart/form-data: | ||
schema: | ||
$ref: '#/components/schemas/Request' | ||
parameters: [] | ||
components: | ||
schemas: | ||
User: | ||
title: User | ||
type: object | ||
description: '' | ||
x-examples: {} | ||
properties: | ||
integerValue: | ||
type: integer | ||
Request: | ||
title: Request | ||
type: object | ||
properties: | ||
user1: | ||
$ref: '#/components/schemas/User' |
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.
@0x0c is it necessary to check is it's not container?
This implementation is different from
modelEnum.mustache
, is it normal?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.
Maybe it's related to #11202 (comment)?
If it's correct being different and you could give a bit of more context, I would appreciate it.
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.
If
modelEnumDeclaration.mustache
is container, the enum confirms String. Therefore, we have to check whether the enum is container or not.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.
And this doesn't apply also to
modelInlineEnumDeclaration.mustache
?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.
Oh, sorry I missed type. In previous my post "If
modelEnumDeclaration.mustache
is container ..." is not correct.. "IfmodelInlineEnumDeclaration.mustache
is container ..." is correct.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.
This PR looks good to me.
If you could explain why we need to check for container in one but not the other I would appreciate it, because this was something that was always a bit confusing to me
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.
Sorry, I can't answer your question because a code for checking container is already implemented before I modify
modelEnumDeclaration.mustache
. I respect original mustache and don't change the mustache is better I think.Originally, according to the first commit of these files, there is difference between
modelEnum.mustache
andmodelInlineEnumDeclaration.mustache
. One is checking for container and other is not.See here and here.
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.
I see, thanks for the explanation 👍