Skip to content

Commit f46160f

Browse files
gitmodimoRafał Hibner
authored andcommitted
Update generated files
1 parent 401899c commit f46160f

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

samples/learn/schema/StarWarsSharedTypes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ service::AwaitableResolver Result<learn::Episode>::convert(service::AwaitableSca
5050
return ModifiedResult<learn::Episode>::resolve(std::move(result), std::move(params),
5151
[](learn::Episode value, const ResolverParams&)
5252
{
53-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesEpisode[static_cast<std::size_t>(value)] } } } };
53+
const size_t idx = static_cast<size_t>(value);
54+
if (idx >= s_namesEpisode.size())
55+
{
56+
throw service::schema_exception { { R"ex(Enum value out of range for Episode)ex" } };
57+
}
58+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesEpisode[idx] } } } };
5459
});
5560
}
5661

samples/proxy/schema/ProxySharedTypes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ service::AwaitableResolver Result<proxy::OperationType>::convert(service::Awaita
5050
return ModifiedResult<proxy::OperationType>::resolve(std::move(result), std::move(params),
5151
[](proxy::OperationType value, const ResolverParams&)
5252
{
53-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesOperationType[static_cast<std::size_t>(value)] } } } };
53+
const size_t idx = static_cast<size_t>(value);
54+
if (idx >= s_namesOperationType.size())
55+
{
56+
throw service::schema_exception { { R"ex(Enum value out of range for OperationType)ex" } };
57+
}
58+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesOperationType[idx] } } } };
5459
});
5560
}
5661

samples/today/nointrospection/TodaySharedTypes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ service::AwaitableResolver Result<today::TaskState>::convert(service::AwaitableS
5050
return ModifiedResult<today::TaskState>::resolve(std::move(result), std::move(params),
5151
[](today::TaskState value, const ResolverParams&)
5252
{
53-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[static_cast<std::size_t>(value)] } } } };
53+
const size_t idx = static_cast<size_t>(value);
54+
if (idx >= s_namesTaskState.size())
55+
{
56+
throw service::schema_exception { { R"ex(Enum value out of range for TaskState)ex" } };
57+
}
58+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[idx] } } } };
5459
});
5560
}
5661

samples/today/schema/TodaySharedTypes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ service::AwaitableResolver Result<today::TaskState>::convert(service::AwaitableS
5050
return ModifiedResult<today::TaskState>::resolve(std::move(result), std::move(params),
5151
[](today::TaskState value, const ResolverParams&)
5252
{
53-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[static_cast<std::size_t>(value)] } } } };
53+
const size_t idx = static_cast<size_t>(value);
54+
if (idx >= s_namesTaskState.size())
55+
{
56+
throw service::schema_exception { { R"ex(Enum value out of range for TaskState)ex" } };
57+
}
58+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[idx] } } } };
5459
});
5560
}
5661

samples/validation/schema/ValidationSharedTypes.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ service::AwaitableResolver Result<validation::DogCommand>::convert(service::Awai
5050
return ModifiedResult<validation::DogCommand>::resolve(std::move(result), std::move(params),
5151
[](validation::DogCommand value, const ResolverParams&)
5252
{
53-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDogCommand[static_cast<std::size_t>(value)] } } } };
53+
const size_t idx = static_cast<size_t>(value);
54+
if (idx >= s_namesDogCommand.size())
55+
{
56+
throw service::schema_exception { { R"ex(Enum value out of range for DogCommand)ex" } };
57+
}
58+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDogCommand[idx] } } } };
5459
});
5560
}
5661

@@ -102,7 +107,12 @@ service::AwaitableResolver Result<validation::CatCommand>::convert(service::Awai
102107
return ModifiedResult<validation::CatCommand>::resolve(std::move(result), std::move(params),
103108
[](validation::CatCommand value, const ResolverParams&)
104109
{
105-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesCatCommand[static_cast<std::size_t>(value)] } } } };
110+
const size_t idx = static_cast<size_t>(value);
111+
if (idx >= s_namesCatCommand.size())
112+
{
113+
throw service::schema_exception { { R"ex(Enum value out of range for CatCommand)ex" } };
114+
}
115+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesCatCommand[idx] } } } };
106116
});
107117
}
108118

src/introspection/IntrospectionSharedTypes.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ service::AwaitableResolver Result<introspection::TypeKind>::convert(service::Awa
5050
return ModifiedResult<introspection::TypeKind>::resolve(std::move(result), std::move(params),
5151
[](introspection::TypeKind value, const ResolverParams&)
5252
{
53-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTypeKind[static_cast<std::size_t>(value)] } } } };
53+
const size_t idx = static_cast<size_t>(value);
54+
if (idx >= s_namesTypeKind.size())
55+
{
56+
throw service::schema_exception { { R"ex(Enum value out of range for __TypeKind)ex" } };
57+
}
58+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTypeKind[idx] } } } };
5459
});
5560
}
5661

@@ -102,7 +107,12 @@ service::AwaitableResolver Result<introspection::DirectiveLocation>::convert(ser
102107
return ModifiedResult<introspection::DirectiveLocation>::resolve(std::move(result), std::move(params),
103108
[](introspection::DirectiveLocation value, const ResolverParams&)
104109
{
105-
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDirectiveLocation[static_cast<std::size_t>(value)] } } } };
110+
const size_t idx = static_cast<size_t>(value);
111+
if (idx >= s_namesDirectiveLocation.size())
112+
{
113+
throw service::schema_exception { { R"ex(Enum value out of range for __DirectiveLocation)ex" } };
114+
}
115+
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDirectiveLocation[idx] } } } };
106116
});
107117
}
108118

0 commit comments

Comments
 (0)