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

Fix examples generation #77

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Fix examples generation #77

wants to merge 5 commits into from

Conversation

bopm
Copy link
Contributor

@bopm bopm commented Aug 16, 2021

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


{ name => value }
end
[ name, value ]

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)

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]

@@ -21,8 +21,8 @@ def initialize(name, param_type, type, required, schema)

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

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]

@@ -31,7 +31,7 @@ def clear

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' } } }

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
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.

processed
end

def name
processed[:name]
end

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

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