-
-
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 11 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}}{ | ||
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. @0x0c another nit that I found is that at the end of the line, there is a space before the final
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. |
||
{{/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 just a small nit, could you please make this in one line to improve the generated code?
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.
Done with 8b1529f
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.
Thanks, could you please update the sample projects also?
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.
OK!
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.
The last commit brought a lot of undesired changes, could you please revert it?
Maybe you need to first merge the master branch into yours and then run the following commands.
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.
Done with 5a1661b and 51fe33f
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.
Could you please explain why some enums are not JSONEncodable?
Is there any issue that you found?
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.
Since enum value that confirms
RawRepresentable
a.k.a primitive value is already confirmJSONEncodable
here and here, it seems to thatmodelEnum.mustache
andmodelInlineEnumDeclaration.mustache
should not confirmJSONCodable
. If confirm explicitly, Xcode could not build generated source code.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.
You are right, thanks 👍