MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / scalar_schema

Method scalar_schema

ra-rpc/src/openapi.rs:831–868  ·  view source on GitHub ↗
(&mut self, field: &FieldDescriptorProto)

Source from the content-addressed store, hash-verified

829 }
830
831 fn scalar_schema(&mut self, field: &FieldDescriptorProto) -> Result<Value> {
832 Ok(match field_type(field) {
833 FieldType::Double => json!({"type": "number", "format": "double"}),
834 FieldType::Float => json!({"type": "number", "format": "float"}),
835 FieldType::Int64 | FieldType::Sint64 | FieldType::Sfixed64 => {
836 json!({"type": "integer", "format": "int64"})
837 }
838 FieldType::Uint64 | FieldType::Fixed64 => {
839 json!({"type": "integer", "format": "uint64"})
840 }
841 FieldType::Int32 | FieldType::Sint32 | FieldType::Sfixed32 => {
842 json!({"type": "integer", "format": "int32"})
843 }
844 FieldType::Uint32 | FieldType::Fixed32 => {
845 json!({"type": "integer", "format": "uint32"})
846 }
847 FieldType::Bool => json!({"type": "boolean"}),
848 FieldType::String => json!({"type": "string"}),
849 FieldType::Bytes => json!({"type": "string", "format": "byte"}),
850 FieldType::Enum => {
851 let type_name = field
852 .type_name
853 .as_ref()
854 .ok_or_else(|| anyhow!("enum field missing type name"))?;
855 self.schema_ref(type_name)?
856 }
857 FieldType::Message => {
858 let type_name = field
859 .type_name
860 .as_ref()
861 .ok_or_else(|| anyhow!("message field missing type name"))?;
862 self.schema_ref(type_name)?
863 }
864 FieldType::Group => {
865 bail!("group fields are not supported in OpenAPI export")
866 }
867 })
868 }
869
870 fn map_field_schema(&mut self, entry: &MessageInfo) -> Result<Value> {
871 let mut value_field = None;

Callers 2

field_schemaMethod · 0.80
map_field_schemaMethod · 0.80

Calls 3

field_typeFunction · 0.85
schema_refMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected