profile
viewpoint
dsalamau dsalamau Full Stack Software Engineer

kalys/tiligram 1

Kyrgyz-russian, russian-kyrgyz dictionary telegram bot. It uses database of http://tili.kg

dsalamau/bitcoin.org 0

Bitcoin.org website

dsalamau/blockchain-developers-09-18 0

Репозиторий курса для блокчейн разработчиков, стартующий осенью 2018 года

dsalamau/con-con 0

The platform is for journalists. They can download and sell their publications through Stripe integrated.

dsalamau/currency-rate 0

Converter for fiat and crypto currencies

dsalamau/dartifact 0

a Web-UI framework with nestable components written in Dart

dsalamau/ilost 0

This is the platform that could be useful for people who lost or found something.

dsalamau/import_example 0

Example for reporting an issue to https://github.com/dry-rb/dry-rails

dsalamau/kycnot 0

Don't get KYC'ed

dsalamau/model 0

Ruby persistence framework with entities and repositories

issue commentrswag/rswag

Parameters always empty

@deXterbed can you please have a look?

heaven

comment created time in 10 hours

PR opened rswag/rswag

Inherit consumes from swagger schema. Addresses #320.

Currently, every example should specify the consumes attribute. If it's missing this leads to a problem described in #320.

To avoid this we can inherit the default consumes attribute defined in swagger_helper with the ability to overwrite it in every example.

+1 -1

0 comment

1 changed file

pr created time in 10 hours

issue commentrswag/rswag

Parameters always empty

The problem is on this line: https://github.com/codeart/rswag/blob/deb4f52884a88ced5c6c4ad06b64404701f10ef4/rswag-specs/lib/rswag/specs/swagger_formatter.rb#L59

I just put debugger there and can see it's nil.

Adding consumes to my spec like this fixed the problem:

consumes 'application/json'
parameter name: :registration, in: :body, schema: {
  '$ref' => '#/components/schemas/registration'
}

This is strange because I have this in swagger_spec.rb:

config.swagger_docs = {
  'v1/swagger.yaml' => {
    openapi:    '3.0.1',
    info:       {
      title:   'User API',
      version: 'v1'
    },
    paths:      {},
    servers:    [...],
    consumes:   ['application/json', 'multipart/form-data', 'application/x-www-form-urlencoded'],
    produces:   ['application/json'],
    basePath:   '/api/v1',
    components: {
heaven

comment created time in 11 hours

issue commentrswag/rswag

Parameters always empty

@heaven did you also update the definition inside the let(:registraion) block, it should also have the registration key, something like this:

let(:registration) { { registration: attributes_for(:user, first_name: 'xyz') }}
heaven

comment created time in 11 hours

issue commentrswag/rswag

Parameters always empty

@deXterbed it clearly tries to do something with the body params here: https://github.com/codeart/rswag/blob/deb4f52884a88ced5c6c4ad06b64404701f10ef4/rswag-specs/lib/rswag/specs/swagger_formatter.rb#L61

Trying to convert them perhaps to the new format and then deletes them here: https://github.com/codeart/rswag/blob/deb4f52884a88ced5c6c4ad06b64404701f10ef4/rswag-specs/lib/rswag/specs/swagger_formatter.rb#L67

heaven

comment created time in 11 hours

issue commentrswag/rswag

Parameters always empty

@deXterbed I just tried this:

parameter name: :registration, in: :body, schema: {
  type:       :object,
  properties: {
    name: :registration,
    registration: {
      type:       :object,
      properties: {
        kind:                  { type: :string, enum: Member.kinds.keys },
        email:                 { type: :string },
        first_name:            { type: :string },
        last_name:             { type: :string },
        password:              { type: :string },
        password_confirmation: { type: :string }
      },
      required:   %i[kind email first_name last_name password password_confirmation]
    }
  }
}

No luck, the registration param doesn't show in the Swagger UI.

heaven

comment created time in 11 hours

issue openedrswag/rswag

Basic auth enables for all routes (!) not only rswag routes.

Hello!

Today I've deploy my app with presented in main readme doc code:

Rswag::Ui.configure do |c|
  c.basic_auth_enabled = true
  c.basic_auth_credentials 'username', 'password'
end

And this code enabled http basic auth for all my routes, not only for rswag engine :) I don't research this problem currrently, but I think I will research it. Just know about this problem. I don't exclude what this problem relates with my specific app configuration.

Have a nice day.

created time in 11 hours

issue commentrswag/rswag

Parameters always empty

Sure, here's the schema:

schemas:     {
  null: {
    type: :null
  },

  registration: {
    type:       :object,
    properties: {
      kind:                  { type: :string, enum: Member.kinds.keys },
      email:                 { type: :string },
      first_name:            { type: :string },
      last_name:             { type: :string },
      password:              { type: :string },
      password_confirmation: { type: :string }
    },
    required:   %i[kind email first_name last_name password password_confirmation]
  },

Our schema file on another project is 3k lines, putting that to specs doesn't seem reasonable. Even though this might work but there's definitely a bug.

heaven

comment created time in 12 hours

issue commentrswag/rswag

Parameters always empty

@heaven you might have to explicitly add that parameter in the schema, i personally avoid using '$ref' for readability, so this is how i've done it for one of my tests:

parameter({
        name: :user, 
        in: :body, 
        schema: {
          type: :object,
          properties: {
            name: :user,
            user: {
              type: :object,
              properties: {
                first_name: { type: :string, example: 'John' },
                last_name: { type: :string, example: 'Doe' },
                email: { type: :string, example: 'john@doe.com' },
                password: { type: :string, example: '123456' }
              }
            }
          },
        }
      })
heaven

comment created time in 12 hours

issue commentrswag/rswag

Parameters always empty

@heaven can you share the schema for registration ?

heaven

comment created time in 12 hours

issue commentrswag/rswag

Parameters always empty

@deXterbed Yep, here's the spec I created yesterday:

require 'swagger_helper'

describe 'Registration API', swagger_doc: 'v1/swagger.yaml' do
  path '/registration' do
    post 'Creates a Member account' do
      tags 'Registrations'

      parameter name: :registration, in: :body, schema: {
        '$ref' => '#/components/schemas/registration'
      }

      let(:registration) do
        {
          kind:                  Member.kinds.keys.sample,
          email:                 Faker::Internet.email,
          first_name:            Faker::Name.first_name,
          last_name:             Faker::Name.last_name,
          password:              "Test1234",
          password_confirmation: "Test1234"
        }
      end

      response '201', 'Created' do
        schema '$ref' => '#/components/schemas/user_access_token'

        run_test! do |response|
          expect(Member.count).to eq 1
          expect(Member.last.access_tokens.last.key).to eq parsed(response)[:user_access_token][:key]
        end
      end

      response '422', 'Unprocessable Entity' do
        let(:registration) do
          {
            kind:                  Member.kinds.keys.sample,
            first_name:            Faker::Name.first_name,
            last_name:             Faker::Name.last_name,
            password:              "Test1234",
            password_confirmation: "Test1234"
          }
        end

        run_test!
      end
    end
  end
end

The spec works (and it did before) but the swagger.yml is wrong and the UI doesn't work as expected. This is how it looks like: Screen shot 2021-01-22 at 11 13 41

You can see no registration body parameter.

This https://github.com/codeart/rswag/commit/deb4f52884a88ced5c6c4ad06b64404701f10ef4 brings the body parameter back to the UI so front-end developers who work with this API can at least see the parameners. But when you try to send a test request from the UI registration body parameter is missing in the request.

heaven

comment created time in 12 hours

issue commentrswag/rswag

Parameters always empty

@heaven did you try using let within the response block? Something like this:

image

heaven

comment created time in 12 hours

issue commentrswag/rswag

Parameters always empty

I am on 2.3.1 and it doesn't work. The problem is in the UI, when you click try it out -> execute: Screen shot 2021-01-22 at 10 59 56

heaven

comment created time in 13 hours

issue commentrswag/rswag

How to mock request and response with webmock or VCR

I made it work using the alternative syntax, apparently, this is the only possible way.

Using vcr (6.0.0) and rswag (2.3.1)

response '200', 'OK' do
  it 'returns a valid 201 response' do |example|
    VCR.use_cassette('success') do
      submit_request(example.metadata)
      assert_response_matches_metadata(example.metadata)
    end
  end
end
vittoriabitton

comment created time in a day

pull request commentrswag/rswag

Configurable Host header

Is there a chance that this PR will be accepted?

amiuhle

comment created time in a day

issue commentrswag/rswag

No way to set several examples for responses with the same HTTP code

Would be super cool to merge this!

dmytro-savochkin

comment created time in 2 days

issue commentrswag/rswag

No way to set several examples for responses with the same HTTP code

@ai-oleynikov Yep, thank you, the approach you linked seems like a good one! Probably if it's merged it can close this issue.

dmytro-savochkin

comment created time in 2 days

pull request commentrswag/rswag

Allow only schema type specification on parameters

Sorry for the late answer.

I checked again on the current master (83567e0ee24dfd77fff96450e3b3031c7da81ec4) and I need both mentions to avoid the error:

      parameter name: :query,
        in: :query,
        type: :string,
        schema: { type: :string },
        required: false

Which generates this JSON in the swagger

"parameters": [
          {
            "name": "query",
            "in": "query",
            "type": "string",
            "schema": {
              "type": "string"
            },
            "required": false
          }

For me both the inline version and the schema version of type specifications fail when specified alone. Looking at the other PRs, it seems other people are running in the same issue (for instance https://github.com/rswag/rswag/pull/319, if you look at the example type param is duplicated)

I run my project with a modified fork, but I think it would nice to have the mainstream project cleaned as well.

hrakotobe

comment created time in 4 days

push eventdry-rb/dry-rails

dry-bot

commit sha 6fe70089599bfa9ed0316fd1e90be4322c193454

[devtools] sync

view details

push time in 7 days

issue closedrswag/rswag

Update endpoint example

The documentation doesn't seem to flesh out how a put or patch would work. I'm struggling to figure out how to correctly structure a patch request to get a working 200 test. I have 204 covered now, but I don't fully understand how to set up a put/patch and there's nothing in the docs. Any help even just pointing to a working example of how it should look, would be awesome.

closed time in 7 days

jtmkrueger

issue commentrswag/rswag

Update endpoint example

NM, I figured this out on my end.

jtmkrueger

comment created time in 7 days

issue commentrswag/rswag

Update endpoint example

So I already figured this much out. As I stated above, I have a 204 example covered, but can't figure out how to put and get a 200.

jtmkrueger

comment created time in 8 days

issue commentrswag/rswag

Update endpoint example

Just like how the documentation does a post request you can substitute it with put or patch:

  path '/blogs' do

    post 'Creates a blog' do
 path '/blogs/{id}' do

   put 'Updates a blog' do
jtmkrueger

comment created time in 8 days

issue openedrswag/rswag

Update endpoint example

The documentation doesn't seem to flesh out how a put or patch would work. I'm struggling to figure out how to correctly structure a patch request to get a working 200 test. I have 204 covered now, but I don't fully understand how to set up a put/patch and there's nothing in the docs. Any help even just pointing to a working example of how it should look, would be awesome.

created time in 8 days

issue commenttmm1/rbtrace

--memory gives me a ArgumentError: command is too long

Is the BUF_SIZE of 120 a hard limit on OSX?

arthurnn

comment created time in 9 days

startedYegorov/awesome-ruby-blogs

started time in 13 days

pull request commentrswag/rswag

Allow only schema type specification on parameters

I have encountered the error related to this. When swaggerizing schema with --dry-run option turned off, SwaggerFormatter deletes type key from parameter hash and nests it inside schema/type key after the first example. Same mutated parameters array is used for every subsequent example.

Parameters in the first example:

[{:name=>:id, :in=>:query, :type=>:id, :required=>true}]

Parameters in every other example:

[{:name=>:id, :in=>:query, :required=>true, :schema=>{:type=>:string}}]

This should fix or at least hide this issue

hrakotobe

comment created time in 18 days

issue commentrswag/rswag

API versioning in #path

You can add basePath: "/api/v1/" to your swagger_helper file. But after that your yaml file will not be valid. But it works. it was discussed here: https://github.com/rswag/rswag/issues/318

dominikdarnel

comment created time in 19 days

created repositorympapis/math_parser

created time in 19 days

push eventdry-rb/dry-rails

dry-bot

commit sha 6475180178c7e639b1cb311cff6c18845cdc73d1

[devtools] sync

view details

push time in 19 days

more