getappmap / getappmap/appmap-js

'content' output is missing for OpenAPI generation

Open
#537 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
53
Forks
18
Avg merge
3d 18h
Merged PRs (30d)
8

Description

As reported in Discord:

https://discord.com/channels/766016904056930325/766022847155535933/938702938321354773

See below for the report.

OpenAPI is generated by appmap-js, using the openapi command:

https://appland.com/docs/reference/cli-client.html#openapi

It crawls over all the AppMaps and reverse-engineers the OpenAPI YAML document from the observed web service calls.

Some information such as the content is reported missing. This should be populated with at least a MIME Type. Maybe the code is looking for the outdated field http_server_response.mime_type instead of http_server_response.headers?


Hey I am trying to generate swagger documentation using appmap
i was following this:

https://appland.com/docs/reference/appmap-swagger-ruby.html

for my test cases, i am using RSpec (type: request) and factory_bot

I was able to generate the swagger docs but the POST API request doesn't contain any request body

My question is do I specifically need to update the openapi_stable.yaml file to generate it correctly
or do I need to write the request spec in rswag format because curently i am doing it like this

require 'rails_helper'

RSpec.describe 'Api::V1::Users', type: :request do
  describe 'POST /api/v1/users/' do
    it 'creates a new user' do
      total_users = User.all.count
      request_body = {
        user: {
          fullname: 'New User',
          email: 'new@gmail.com',
          password: 'asdasd12ad'
        }
      }
      post api_v1_users_path, params: request_body
      expect(response).to have_http_status(201)
      expect(User.all.count).to eq(total_users + 1)
    end
  end
end
---
openapi: 3.0.1
info:
  title: Rails api
  version: v1.0
paths:
  "/api/v1/users":
    post:
      responses:
        '201':
          content: {}
        '422':
          content: {}
components:
  securitySchemes: {}
servers:
- url: http://{defaultHost}
  variables:
    defaultHost:
      default: localhost:3000

Screenshot_from_2022-02-03_13-32-42

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the appmap-js openapi command described in the issue and trace how observed web service responses become the generated OpenAPI YAML. Compare the use of http_server_response.mime_type with the available http_server_response.headers; done means generated response content includes at least the observed MIME type.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.