Skip to content

Fix examples generation#77

Draft
bopm wants to merge 5 commits intozhandao:masterfrom
bopm:fix-examples
Draft

Fix examples generation#77
bopm wants to merge 5 commits intozhandao:masterfrom
bopm:fix-examples

Conversation

@bopm
Copy link
Copy Markdown
Contributor

@bopm bopm commented Aug 16, 2021

Examples should have different location and format according to OAS 3.0.


{ name => value }
end
[ name, value ]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideArrayLiteralBrackets: Do not use space inside array brackets.

desc = schema.processed[:description]
processed[:description] = desc if desc
processed[:description] = processed[:schema].delete(:description) if processed[:schema].key?(:description)
processed[:examples] = processed[:schema].delete(:examples) if processed[:schema].key?(:examples)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [105/80]

processed[:schema] = schema.process
desc = schema.processed[:description]
processed[:description] = desc if desc
processed[:description] = processed[:schema].delete(:description) if processed[:schema].key?(:description)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [114/80]

desc :example, subject: :examples do
mk -> { example :ExampleA, { }; example :ExampleZ, { } }, doc_will_has_keys: { examples: %i[ ExampleA ExampleZ ] }; clear
mk -> { example :ExampleA, { name: 'BeiGou' } }, get: { ExampleA: [{ name: { value: 'BeiGou' } }] }
mk -> { example :ExampleA, { name: 'BeiGou' } }, get: { ExampleA: { name: { value: 'BeiGou' } } }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Metrics/LineLength: Line is too long. [101/80]

@bopm
Copy link
Copy Markdown
Contributor Author

bopm commented Aug 16, 2021

During generating examples for query param, I stepped on the fact, that while example should be sitting in the schema, examples should be one level higher. And they are supposed to be a single object, not an array of single key objects.
https://swagger.io/docs/specification/adding-examples/
While I was able to fix the issue and get Swagger UI to show me examples with extended properties like summary fixing specs is a way more complicated issue with RSpec DSL present. Looking forward to some guidance @zhandao.

end

def extract_from_schema(key)
processed[key] = processed[:schema].delete(key) if processed[:schema].key?(key)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [87/80]

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

Successfully merging this pull request may close these issues.

2 participants