Sfoglia il codice sorgente

fix: fix example errors of the schema registry endpoints

firest 1 anno fa
parent
commit
8b2814d7b4

+ 3 - 0
apps/emqx_retainer/test/emqx_retainer_SUITE.erl

@@ -107,6 +107,9 @@ end_per_testcase(t_cursor_cleanup, _Config) ->
 end_per_testcase(_TestCase, _Config) ->
     ok.
 
+app_spec() ->
+    {emqx_retainer, ?BASE_CONF}.
+
 app_spec(disabled) ->
     {emqx_retainer, ?DISABLED_CONF};
 app_spec(_) ->

+ 1 - 1
apps/emqx_schema_registry/src/emqx_schema_registry.app.src

@@ -1,6 +1,6 @@
 {application, emqx_schema_registry, [
     {description, "EMQX Schema Registry"},
-    {vsn, "0.3.4"},
+    {vsn, "0.3.5"},
     {registered, [emqx_schema_registry_sup]},
     {mod, {emqx_schema_registry_app, []}},
     {included_applications, [

+ 29 - 17
apps/emqx_schema_registry/src/emqx_schema_registry_http_api.erl

@@ -106,14 +106,14 @@ schema("/schema_registry/:name") ->
             parameters => [param_path_schema_name()],
             'requestBody' => emqx_dashboard_swagger:schema_with_examples(
                 emqx_schema_registry_schema:api_schema("put"),
-                post_examples()
+                put_examples()
             ),
             responses =>
                 #{
                     200 =>
                         emqx_dashboard_swagger:schema_with_examples(
                             emqx_schema_registry_schema:api_schema("put"),
-                            put_examples()
+                            post_examples()
                         ),
                     404 => error_schema('NOT_FOUND', "Schema not found")
                 }
@@ -157,14 +157,14 @@ schema("/schema_registry_external") ->
             description => ?DESC("external_registry_create"),
             'requestBody' => emqx_dashboard_swagger:schema_with_examples(
                 hoconsc:union(fun create_external_registry_union/1),
-                post_examples()
+                create_external_registry_input_examples(post)
             ),
             responses =>
                 #{
                     201 =>
                         emqx_dashboard_swagger:schema_with_examples(
                             emqx_schema_registry_schema:external_registry_type(),
-                            post_examples()
+                            create_external_registry_input_examples(get)
                         ),
                     400 => error_schema('ALREADY_EXISTS', "Schema already exists")
                 }
@@ -182,8 +182,8 @@ schema("/schema_registry_external/registry/:name") ->
                 #{
                     200 =>
                         emqx_dashboard_swagger:schema_with_examples(
-                            emqx_schema_registry_schema:api_schema("get"),
-                            get_examples()
+                            emqx_schema_registry_schema:external_registry_type(),
+                            create_external_registry_input_examples(put)
                         ),
                     404 => error_schema('NOT_FOUND', "Schema not found")
                 }
@@ -195,14 +195,14 @@ schema("/schema_registry_external/registry/:name") ->
             parameters => [param_path_external_registry_name()],
             'requestBody' => emqx_dashboard_swagger:schema_with_examples(
                 emqx_schema_registry_schema:external_registry_type(),
-                create_external_registry_input_examples()
+                create_external_registry_input_examples(put)
             ),
             responses =>
                 #{
                     200 =>
                         emqx_dashboard_swagger:schema_with_examples(
-                            emqx_schema_registry_schema:api_schema("put"),
-                            put_examples()
+                            emqx_schema_registry_schema:external_registry_type(),
+                            create_external_registry_input_examples(put)
                         ),
                     404 => error_schema('NOT_FOUND', "Schema not found")
                 }
@@ -360,23 +360,32 @@ sample_get_schema_response(avro) ->
         description => <<"My Avro Schema">>,
         source => <<
             "{\"type\":\"record\","
+            "\"name\":\"test\","
             "\"fields\":[{\"type\":\"int\",\"name\":\"i\"},"
             "{\"type\":\"string\",\"name\":\"s\"}]}"
         >>
     }.
 
+sample_get_schema_response(avro, put) ->
+    maps:without([name], sample_get_schema_response(avro));
+sample_get_schema_response(avro, _Method) ->
+    sample_get_schema_response(avro).
+
 put_examples() ->
-    post_examples().
+    example_template(put).
 
 post_examples() ->
-    get_examples().
+    example_template(post).
 
 get_examples() ->
+    example_template(get).
+
+example_template(Method) ->
     #{
         <<"avro_schema">> =>
             #{
                 summary => <<"Avro">>,
-                value => sample_get_schema_response(avro)
+                value => sample_get_schema_response(avro, Method)
             }
     }.
 
@@ -386,6 +395,7 @@ sample_list_external_registries_response() ->
 sample_get_external_registry_response(confluent) ->
     #{
         type => <<"confluent">>,
+        name => <<"test">>,
         url => <<"http://confluent_schema_registry:8081">>,
         auth => #{
             mechanism => <<"basic">>,
@@ -394,18 +404,20 @@ sample_get_external_registry_response(confluent) ->
         }
     }.
 
-create_external_registry_input_examples() ->
+sample_get_external_registry_response(confluent, put) ->
+    maps:without([name], sample_get_external_registry_response(confluent));
+sample_get_external_registry_response(confluent, _Method) ->
+    sample_get_external_registry_response(confluent).
+
+create_external_registry_input_examples(Method) ->
     #{
         <<"confluent">> =>
             #{
                 summary => <<"Confluent">>,
-                value => external_registry_confluent_example()
+                value => sample_get_external_registry_response(confluent, Method)
             }
     }.
 
-external_registry_confluent_example() ->
-    #{}.
-
 %%-------------------------------------------------------------------------------------------------
 %% Schemas and hocon types
 %%-------------------------------------------------------------------------------------------------

+ 1 - 0
changes/ee/fix-14217.en.md

@@ -0,0 +1 @@
+Fixed example errors of the schema registry endpoints.