From 0bfc174d26dfa79aefa172f30e4ec4cb5af9873f Mon Sep 17 00:00:00 2001 From: Sasha Melentyev Date: Mon, 7 Feb 2022 13:24:46 +0300 Subject: [PATCH] fix(api): skip status less 200 or greatest or equal 300 --- internal/api/build.go | 4 ++++ test/testdata/openapi.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/internal/api/build.go b/internal/api/build.go index 1fb4f23..80dd574 100644 --- a/internal/api/build.go +++ b/internal/api/build.go @@ -179,6 +179,10 @@ func (b *Builder) Set(path, method string, o *openapi.Operation) (Operation, err return Operation{}, err } + if statusCode < http.StatusOK || statusCode >= http.StatusMultipleChoices { + continue + } + content, ok := resp.Content["application/json"] if !ok { operation.Responses = append(operation.Responses, Response{ diff --git a/test/testdata/openapi.yml b/test/testdata/openapi.yml index 64ab86b..e397262 100644 --- a/test/testdata/openapi.yml +++ b/test/testdata/openapi.yml @@ -24,6 +24,8 @@ paths: id: e1afccea-5168-4735-84d4-cb96f6fb5d25 firstName: Elon lastName: Musk + '500': + description: '' get: responses: '200':