Skip to content

Commit 7b54542

Browse files
committed
update samples
1 parent abd8437 commit 7b54542

File tree

3 files changed

+70
-7
lines changed
  • samples
    • client/petstore/cpp-restsdk/client
    • server/petstore/scala-http4s-server/src/main/scala/org/openapitools/models

3 files changed

+70
-7
lines changed

samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ class Pet
109109
void unsetStatus();
110110
void setStatus(const StatusEnum value);
111111

112-
Object getMetadata() const;
112+
std::shared_ptr<Object> getMetadata() const;
113113
bool metadataIsSet() const;
114114
void unsetMetadata();
115-
void setMetadata(const Object& value);
115+
void setMetadata(const std::shared_ptr<Object>& value);
116116

117117

118118
protected:
@@ -134,7 +134,7 @@ class Pet
134134
StatusEnum m_Status;
135135
bool m_StatusIsSet;
136136

137-
Object m_Metadata;
137+
std::shared_ptr<Object> m_Metadata;
138138
bool m_MetadataIsSet;
139139

140140
};

samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ bool Pet::fromJson(const web::json::value& val)
159159
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("metadata")));
160160
if(!fieldValue.is_null())
161161
{
162-
Object refVal_setMetadata;
162+
std::shared_ptr<Object> refVal_setMetadata;
163163
ok &= ModelBase::fromJson(fieldValue, refVal_setMetadata);
164164
setMetadata(refVal_setMetadata);
165165

@@ -252,7 +252,7 @@ bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const util
252252
}
253253
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("metadata"))))
254254
{
255-
Object refVal_setMetadata;
255+
std::shared_ptr<Object> refVal_setMetadata;
256256
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("metadata"))), refVal_setMetadata );
257257
setMetadata(refVal_setMetadata);
258258
}
@@ -418,13 +418,13 @@ void Pet::unsetStatus()
418418
{
419419
m_StatusIsSet = false;
420420
}
421-
Object Pet::getMetadata() const
421+
std::shared_ptr<Object> Pet::getMetadata() const
422422
{
423423
return m_Metadata;
424424
}
425425

426426

427-
void Pet::setMetadata(const Object& value)
427+
void Pet::setMetadata(const std::shared_ptr<Object>& value)
428428
{
429429
m_Metadata = value;
430430
m_MetadataIsSet = true;

samples/server/petstore/scala-http4s-server/src/main/scala/org/openapitools/models/types.scala

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,30 @@ import java.time.ZonedDateTime
1919
* @param message
2020
*/
2121

22+
case class ApiResponse(
23+
code: Option[Int],
24+
_type: Option[String],
25+
message: Option[String]
26+
)
27+
object ApiResponse {
28+
implicit val encoderApiResponse: Encoder[ApiResponse] = deriveEncoder[ApiResponse].mapJson(_.dropNullValues)
29+
implicit val decoderApiResponse: Decoder[ApiResponse] = deriveDecoder[ApiResponse]
30+
}
2231

2332
/**
2433
* A category for a pet
2534
* @param id
2635
* @param name
2736
*/
2837

38+
case class Category(
39+
id: Option[Long],
40+
name: Option[Refined[String, MatchesRegex["^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"]]]
41+
)
42+
object Category {
43+
implicit val encoderCategory: Encoder[Category] = deriveEncoder[Category].mapJson(_.dropNullValues)
44+
implicit val decoderCategory: Decoder[Category] = deriveDecoder[Category]
45+
}
2946

3047
/**
3148
* An order for a pets from the pet store
@@ -37,6 +54,18 @@ import java.time.ZonedDateTime
3754
* @param complete
3855
*/
3956

57+
case class Order(
58+
id: Option[Long],
59+
petId: Option[Long],
60+
quantity: Option[Int],
61+
shipDate: Option[ZonedDateTime],
62+
status: Option[String],
63+
complete: Option[Boolean]
64+
)
65+
object Order {
66+
implicit val encoderOrder: Encoder[Order] = deriveEncoder[Order].mapJson(_.dropNullValues)
67+
implicit val decoderOrder: Decoder[Order] = deriveDecoder[Order]
68+
}
4069

4170
/**
4271
* A pet for sale in the pet store
@@ -48,13 +77,33 @@ import java.time.ZonedDateTime
4877
* @param status pet status in the store
4978
*/
5079

80+
case class Pet(
81+
id: Option[Long],
82+
category: Option[Category],
83+
name: String,
84+
photoUrls: List[String],
85+
tags: Option[List[Tag]],
86+
status: Option[String]
87+
)
88+
object Pet {
89+
implicit val encoderPet: Encoder[Pet] = deriveEncoder[Pet].mapJson(_.dropNullValues)
90+
implicit val decoderPet: Decoder[Pet] = deriveDecoder[Pet]
91+
}
5192

5293
/**
5394
* A tag for a pet
5495
* @param id
5596
* @param name
5697
*/
5798

99+
case class Tag(
100+
id: Option[Long],
101+
name: Option[String]
102+
)
103+
object Tag {
104+
implicit val encoderTag: Encoder[Tag] = deriveEncoder[Tag].mapJson(_.dropNullValues)
105+
implicit val decoderTag: Decoder[Tag] = deriveDecoder[Tag]
106+
}
58107

59108
/**
60109
* A User who is purchasing from the pet store
@@ -68,4 +117,18 @@ import java.time.ZonedDateTime
68117
* @param userStatus User Status
69118
*/
70119

120+
case class User(
121+
id: Option[Long],
122+
username: Option[String],
123+
firstName: Option[String],
124+
lastName: Option[String],
125+
email: Option[String],
126+
password: Option[String],
127+
phone: Option[String],
128+
userStatus: Option[Int]
129+
)
130+
object User {
131+
implicit val encoderUser: Encoder[User] = deriveEncoder[User].mapJson(_.dropNullValues)
132+
implicit val decoderUser: Decoder[User] = deriveDecoder[User]
133+
}
71134

0 commit comments

Comments
 (0)