`OpenAPI.Spec.merge/2` doesn't merge paths resulting in `paths: nil`
When running generation with additional_files, i.e.:
config :oapi_generator,
tink: [
reader: [
file: "spec.yaml",
additional_files: ["spec.additional.yaml"]
],
naming: [
base_module: Service,
default_operation_module: Operation,
operation_use_tags: true,
field_casing: :snake
],
output: [
base_module: Service,
location: "lib/service",
default_client: Service.Client,
operation_use: Service.Encoder,
extra_fields: [:__meta__]
]
]
OpenAPI.Spec.merge/2's second clause is being called, and it doesn't set paths in resulting spec.
@spec merge(t | nil, t) :: t
defp merge(nil, spec_two), do: spec_two
defp merge(spec_one, spec_two) do
%__MODULE__{
openapi: openapi_one,
info: info_one,
servers: servers_one,
components: components_one,
security: security_one,
tags: tags_one,
external_docs: external_docs_one
} = spec_one
%__MODULE__{
servers: servers_two,
components: components_two,
security: security_two,
tags: tags_two
} = spec_two
%__MODULE__{
openapi: openapi_one,
info: info_one,
servers: servers_one ++ servers_two,
components: Components.merge(components_one, components_two),
security: security_one ++ security_two,
tags: tags_one ++ tags_two,
external_docs: external_docs_one
}
end
IMO we should merge Path.Item's, smth like:
...
path_items: Map.merge(paths_one, paths_two, Path.Item.merge/3)
...
I'll implement it shortly.
Hi @florius0, thanks for reporting this and for the PR. Do you have an example spec for this, or are the additional files created by you? I'd love to take a look, because there might be other places in the code where I made some bad assumptions about how multiple files should come together.
Hi, I don't suppose that I should share the real specs I got this error on, they are some 30k LOC :D, but I may be able to write example specs this week