Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml generation fails to generate a correct tags block. #61

Open
garpur opened this issue May 3, 2019 · 2 comments
Open

Yaml generation fails to generate a correct tags block. #61

garpur opened this issue May 3, 2019 · 2 comments

Comments

@garpur
Copy link

garpur commented May 3, 2019

The write to yaml is broken.
generates:
....
tags:

  • name: Phenotypes foobar
    description: &9 !ruby/string:YARD::Docstring
    str: Some descr
    tags:
    • !ruby/object:YARD::Tags::Tag
      tag_name: resource
      text: Phenotypes foobar
      name:
      types:
      object: &2 !ruby/object:YARD::CodeObjects::ClassObject
      children: !ruby/array:YARD::CodeObjects::CodeObjectList
      ... 1000+ lines of stuff :( ...
      components:
      schemas:
      ...

the json writer generates:
...
"tags": [
{
"name": "Phenotypes foobar",
"description": "Some descr"
}
],
"components": {
...

The tags seems to be the only block that is broken, the other blocks are as expected.

@nicksieger
Copy link
Collaborator

How are you generating YAML? If you're using one of the SwaggerYard::Swagger or OpenAPI objects, may I suggest modifying your code to call the #to_h method first like so:

s = SwaggerYard::Swagger.new
puts YAML::dump(s.to_h)

@garpur
Copy link
Author

garpur commented May 6, 2019

Sorry for being unclear (imprecise)

My config.
`SwaggerYard.configure do |config|
config.title = 'Endpoint reference'
config.description = 'Below is a list of the endpoints in the API along with examples and parameter documentation.'
config.api_version = "0.1"

host = ENV['XXX_ZZZ'] || 'localhost'
config.api_base_path = "https://#{host}/"

config.swagger_version = '3.0'
config.controller_path = Dir.glob Rails.root.join('app/controllers//*').to_s
config.model_path = Dir.glob Rails.root.join('app/serializers/
/*').to_s
end
`

Currently just running interactively in "rails c"
`SwaggerYard.register_custom_yard_tags!

spec = SwaggerYard::OpenAPI.new
File.open("openapi.yml", "w") { |f| f << YAML.dump(spec.to_h) }

specc = SwaggerYard::OpenAPI.new
File.open("openapi.json", "w") { |ff| ff << JSON.pretty_generate(specc.to_h) }
`

This generates a valid .JSON file but the YAML file has noise in the middle.

speccc = SwaggerYard::OpenAPI.new puts YAML::dump(speccc.to_h)
this also generates invalid YAML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants