Skip to content

Commit

Permalink
Bug fixes (#112)
Browse files Browse the repository at this point in the history
* fixing sample data generation for timestamp fields

Signed-off-by: Rajas Panat <rajaspa@amazon.com>

* setting additional properties to false in the json schemas

Signed-off-by: Rajas Panat <rajaspa@amazon.com>

* updating the version

Signed-off-by: Rajas Panat <rajaspa@amazon.com>

---------

Signed-off-by: Rajas Panat <rajaspa@amazon.com>
  • Loading branch information
floydtree authored Oct 11, 2024
1 parent 29c4744 commit 0481e84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/schema/generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ defmodule Schema.Generator do
end

defp generate_data(_name, "timestamp_t", _field),
do: DateTime.utc_now() |> DateTime.to_unix(:microsecond)
do: DateTime.utc_now() |> DateTime.to_unix(:millisecond)

defp generate_data(_name, "datetime_t", _field),
do: DateTime.utc_now() |> DateTime.to_iso8601()
Expand Down
8 changes: 5 additions & 3 deletions lib/schema/json_schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ defmodule Schema.JsonSchema do
else
class_schema(make_class_ref(name, ext))
end
|> empty_object(properties)
|> Map.put("title", type[:caption])
|> Map.put("type", "object")
|> Map.put("properties", properties)
|> Map.put("additionalProperties", false)
|> put_required(required)
|> encode_objects(type[:objects])
|> empty_object(properties)
end

defp add_java_class(obj, name) do
Expand Down Expand Up @@ -78,7 +79,8 @@ defmodule Schema.JsonSchema do
defp class_schema(id) do
%{
"$schema" => @schema_version,
"$id" => id
"$id" => id,
"additionalProperties" => false
}
end

Expand Down Expand Up @@ -185,7 +187,7 @@ defmodule Schema.JsonSchema do
true -> type
end
end

defp encode_object(schema, _name, attr) do
type = attr[:object_type]
Map.put(schema, "$ref", make_object_ref(type))
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defmodule Schema.MixProject do
use Mix.Project

@version "2.73.1"
@version "2.74.0"

def project do
build = System.get_env("GITHUB_RUN_NUMBER") || "SNAPSHOT"
Expand Down

0 comments on commit 0481e84

Please sign in to comment.