From d4e307f0dffe8ab8b5d99cc1f1b089231c2fc120 Mon Sep 17 00:00:00 2001 From: "judy.liu" Date: Fri, 30 Jan 2026 14:47:02 +0800 Subject: [PATCH 1/2] add test code --- packages/typespec-go/.scripts/tspcompile.js | 1 + .../test/http-specs/documentation/LICENSE.txt | 21 +++ .../documentation/fake/zz_internal.go | 40 +++++ .../documentation/fake/zz_lists_server.go | 162 ++++++++++++++++++ .../documentation/fake/zz_server.go | 78 +++++++++ .../fake/zz_textformatting_server.go | 155 +++++++++++++++++ .../test/http-specs/documentation/go.mod | 11 ++ .../test/http-specs/documentation/go.sum | 16 ++ .../documentation/testdata/_metadata.json | 3 + .../http-specs/documentation/zz_client.go | 56 ++++++ .../http-specs/documentation/zz_constants.go | 54 ++++++ .../documentation/zz_lists_client.go | 147 ++++++++++++++++ .../http-specs/documentation/zz_models.go | 34 ++++ .../documentation/zz_models_serde.go | 59 +++++++ .../http-specs/documentation/zz_options.go | 36 ++++ .../http-specs/documentation/zz_responses.go | 35 ++++ .../documentation/zz_textformatting_client.go | 131 ++++++++++++++ .../http-specs/documentation/zz_version.go | 10 ++ 18 files changed, 1049 insertions(+) create mode 100644 packages/typespec-go/test/http-specs/documentation/LICENSE.txt create mode 100644 packages/typespec-go/test/http-specs/documentation/fake/zz_internal.go create mode 100644 packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go create mode 100644 packages/typespec-go/test/http-specs/documentation/fake/zz_server.go create mode 100644 packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go create mode 100644 packages/typespec-go/test/http-specs/documentation/go.mod create mode 100644 packages/typespec-go/test/http-specs/documentation/go.sum create mode 100644 packages/typespec-go/test/http-specs/documentation/testdata/_metadata.json create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_client.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_constants.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_lists_client.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_models.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_models_serde.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_options.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_responses.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go create mode 100644 packages/typespec-go/test/http-specs/documentation/zz_version.go diff --git a/packages/typespec-go/.scripts/tspcompile.js b/packages/typespec-go/.scripts/tspcompile.js index e72958bf23..24d68c28a2 100644 --- a/packages/typespec-go/.scripts/tspcompile.js +++ b/packages/typespec-go/.scripts/tspcompile.js @@ -18,6 +18,7 @@ const compiler = pkgRoot + 'node_modules/@typespec/compiler/cmd/tsp.js'; // 'moduleName': [ 'input', 'emitter option 1', 'emitter option N...' ] // if no .tsp file is specified in input, it's assumed to be main.tsp const httpSpecsGroup = { + 'documentation': ['documentation'], 'apikeygroup': ['authentication/api-key'], // ctors for API key not supported 'customgroup': ['authentication/http/custom'], // ctors for API key not supported 'oauth2group': ['authentication/oauth2'], diff --git a/packages/typespec-go/test/http-specs/documentation/LICENSE.txt b/packages/typespec-go/test/http-specs/documentation/LICENSE.txt new file mode 100644 index 0000000000..48ea6616b5 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_internal.go b/packages/typespec-go/test/http-specs/documentation/fake/zz_internal.go new file mode 100644 index 0000000000..edd9ca564c --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/fake/zz_internal.go @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "net/http" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func initServer[T any](mu *sync.Mutex, dst **T, src func() *T) { + mu.Lock() + if *dst == nil { + *dst = src() + } + mu.Unlock() +} diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go b/packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go new file mode 100644 index 0000000000..4e39a784c4 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "documentation" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// ListsServer is a fake server for instances of the documentation.ListsClient type. +type ListsServer struct { + // BulletPointsModel is the fake for method ListsClient.BulletPointsModel + // HTTP status codes to indicate success: http.StatusOK + BulletPointsModel func(ctx context.Context, input documentation.BulletPointsModel, options *documentation.ListsClientBulletPointsModelOptions) (resp azfake.Responder[documentation.ListsClientBulletPointsModelResponse], errResp azfake.ErrorResponder) + + // BulletPointsOp is the fake for method ListsClient.BulletPointsOp + // HTTP status codes to indicate success: http.StatusNoContent + BulletPointsOp func(ctx context.Context, options *documentation.ListsClientBulletPointsOpOptions) (resp azfake.Responder[documentation.ListsClientBulletPointsOpResponse], errResp azfake.ErrorResponder) + + // Numbered is the fake for method ListsClient.Numbered + // HTTP status codes to indicate success: http.StatusNoContent + Numbered func(ctx context.Context, options *documentation.ListsClientNumberedOptions) (resp azfake.Responder[documentation.ListsClientNumberedResponse], errResp azfake.ErrorResponder) +} + +// NewListsServerTransport creates a new instance of ListsServerTransport with the provided implementation. +// The returned ListsServerTransport instance is connected to an instance of documentation.ListsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewListsServerTransport(srv *ListsServer) *ListsServerTransport { + return &ListsServerTransport{srv: srv} +} + +// ListsServerTransport connects instances of documentation.ListsClient to instances of ListsServer. +// Don't use this type directly, use NewListsServerTransport instead. +type ListsServerTransport struct { + srv *ListsServer +} + +// Do implements the policy.Transporter interface for ListsServerTransport. +func (l *ListsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return l.dispatchToMethodFake(req, method) +} + +func (l *ListsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if listsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = listsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ListsClient.BulletPointsModel": + res.resp, res.err = l.dispatchBulletPointsModel(req) + case "ListsClient.BulletPointsOp": + res.resp, res.err = l.dispatchBulletPointsOp(req) + case "ListsClient.Numbered": + res.resp, res.err = l.dispatchNumbered(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (l *ListsServerTransport) dispatchBulletPointsModel(req *http.Request) (*http.Response, error) { + if l.srv.BulletPointsModel == nil { + return nil, &nonRetriableError{errors.New("fake for method BulletPointsModel not implemented")} + } + type partialBodyParams struct { + Input documentation.BulletPointsModel `json:"input"` + } + body, err := server.UnmarshalRequestAsJSON[partialBodyParams](req) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BulletPointsModel(req.Context(), body.Input, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *ListsServerTransport) dispatchBulletPointsOp(req *http.Request) (*http.Response, error) { + if l.srv.BulletPointsOp == nil { + return nil, &nonRetriableError{errors.New("fake for method BulletPointsOp not implemented")} + } + respr, errRespr := l.srv.BulletPointsOp(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *ListsServerTransport) dispatchNumbered(req *http.Request) (*http.Response, error) { + if l.srv.Numbered == nil { + return nil, &nonRetriableError{errors.New("fake for method Numbered not implemented")} + } + respr, errRespr := l.srv.Numbered(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ListsServerTransport +var listsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_server.go b/packages/typespec-go/test/http-specs/documentation/fake/zz_server.go new file mode 100644 index 0000000000..57ff16fe23 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/fake/zz_server.go @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// Server is a fake server for instances of the documentation.Client type. +type Server struct { + // ListsServer contains the fakes for client ListsClient + ListsServer ListsServer + + // TextFormattingServer contains the fakes for client TextFormattingClient + TextFormattingServer TextFormattingServer +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of documentation.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{srv: srv} +} + +// ServerTransport connects instances of documentation.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + trMu sync.Mutex + trListsServer *ListsServerTransport + trTextFormattingServer *TextFormattingServerTransport +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToClientFake(req, method[:strings.Index(method, ".")]) +} + +func (s *ServerTransport) dispatchToClientFake(req *http.Request, client string) (*http.Response, error) { + var resp *http.Response + var err error + + switch client { + case "ListsClient": + initServer(&s.trMu, &s.trListsServer, func() *ListsServerTransport { + return NewListsServerTransport(&s.srv.ListsServer) + }) + resp, err = s.trListsServer.Do(req) + case "TextFormattingClient": + initServer(&s.trMu, &s.trTextFormattingServer, func() *TextFormattingServerTransport { + return NewTextFormattingServerTransport(&s.srv.TextFormattingServer) + }) + resp, err = s.trTextFormattingServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + return resp, err +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go b/packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go new file mode 100644 index 0000000000..e7f324b4c2 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "documentation" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// TextFormattingServer is a fake server for instances of the documentation.TextFormattingClient type. +type TextFormattingServer struct { + // BoldText is the fake for method TextFormattingClient.BoldText + // HTTP status codes to indicate success: http.StatusNoContent + BoldText func(ctx context.Context, options *documentation.TextFormattingClientBoldTextOptions) (resp azfake.Responder[documentation.TextFormattingClientBoldTextResponse], errResp azfake.ErrorResponder) + + // CombinedFormatting is the fake for method TextFormattingClient.CombinedFormatting + // HTTP status codes to indicate success: http.StatusNoContent + CombinedFormatting func(ctx context.Context, options *documentation.TextFormattingClientCombinedFormattingOptions) (resp azfake.Responder[documentation.TextFormattingClientCombinedFormattingResponse], errResp azfake.ErrorResponder) + + // ItalicText is the fake for method TextFormattingClient.ItalicText + // HTTP status codes to indicate success: http.StatusNoContent + ItalicText func(ctx context.Context, options *documentation.TextFormattingClientItalicTextOptions) (resp azfake.Responder[documentation.TextFormattingClientItalicTextResponse], errResp azfake.ErrorResponder) +} + +// NewTextFormattingServerTransport creates a new instance of TextFormattingServerTransport with the provided implementation. +// The returned TextFormattingServerTransport instance is connected to an instance of documentation.TextFormattingClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTextFormattingServerTransport(srv *TextFormattingServer) *TextFormattingServerTransport { + return &TextFormattingServerTransport{srv: srv} +} + +// TextFormattingServerTransport connects instances of documentation.TextFormattingClient to instances of TextFormattingServer. +// Don't use this type directly, use NewTextFormattingServerTransport instead. +type TextFormattingServerTransport struct { + srv *TextFormattingServer +} + +// Do implements the policy.Transporter interface for TextFormattingServerTransport. +func (t *TextFormattingServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TextFormattingServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if textFormattingServerTransportInterceptor != nil { + res.resp, res.err, intercepted = textFormattingServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TextFormattingClient.BoldText": + res.resp, res.err = t.dispatchBoldText(req) + case "TextFormattingClient.CombinedFormatting": + res.resp, res.err = t.dispatchCombinedFormatting(req) + case "TextFormattingClient.ItalicText": + res.resp, res.err = t.dispatchItalicText(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TextFormattingServerTransport) dispatchBoldText(req *http.Request) (*http.Response, error) { + if t.srv.BoldText == nil { + return nil, &nonRetriableError{errors.New("fake for method BoldText not implemented")} + } + respr, errRespr := t.srv.BoldText(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TextFormattingServerTransport) dispatchCombinedFormatting(req *http.Request) (*http.Response, error) { + if t.srv.CombinedFormatting == nil { + return nil, &nonRetriableError{errors.New("fake for method CombinedFormatting not implemented")} + } + respr, errRespr := t.srv.CombinedFormatting(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TextFormattingServerTransport) dispatchItalicText(req *http.Request) (*http.Response, error) { + if t.srv.ItalicText == nil { + return nil, &nonRetriableError{errors.New("fake for method ItalicText not implemented")} + } + respr, errRespr := t.srv.ItalicText(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TextFormattingServerTransport +var textFormattingServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/packages/typespec-go/test/http-specs/documentation/go.mod b/packages/typespec-go/test/http-specs/documentation/go.mod new file mode 100644 index 0000000000..f661fc2812 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/go.mod @@ -0,0 +1,11 @@ +module documentation + +go 1.24.0 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect + golang.org/x/net v0.49.0 // indirect + golang.org/x/text v0.33.0 // indirect +) diff --git a/packages/typespec-go/test/http-specs/documentation/go.sum b/packages/typespec-go/test/http-specs/documentation/go.sum new file mode 100644 index 0000000000..84a581b2cc --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/packages/typespec-go/test/http-specs/documentation/testdata/_metadata.json b/packages/typespec-go/test/http-specs/documentation/testdata/_metadata.json new file mode 100644 index 0000000000..fe1d7908ed --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/testdata/_metadata.json @@ -0,0 +1,3 @@ +{ + "emitterVersion": "0.0.0" +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_client.go b/packages/typespec-go/test/http-specs/documentation/zz_client.go new file mode 100644 index 0000000000..cf51104dfe --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_client.go @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// Client - Illustrates documentation generation and formatting features +// Don't use this type directly, use NewClientWithNoCredential() instead. +type Client struct { + internal *azcore.Client + endpoint string +} + +// ClientOptions contains the optional values for creating a [Client]. +type ClientOptions struct { + azcore.ClientOptions +} + +// NewClientWithNoCredential creates a new instance of Client with the specified values. +// - endpoint - Service host +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewClientWithNoCredential(endpoint string, options *ClientOptions) (*Client, error) { + if options == nil { + options = &ClientOptions{} + } + cl, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions) + if err != nil { + return nil, err + } + client := &Client{ + endpoint: endpoint, + internal: cl, + } + return client, nil +} + +// NewListsClient creates a new instance of [ListsClient]. +func (client *Client) NewListsClient() *ListsClient { + return &ListsClient{ + endpoint: client.endpoint, + internal: client.internal, + } +} + +// NewTextFormattingClient creates a new instance of [TextFormattingClient]. +func (client *Client) NewTextFormattingClient() *TextFormattingClient { + return &TextFormattingClient{ + endpoint: client.endpoint, + internal: client.internal, + } +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_constants.go b/packages/typespec-go/test/http-specs/documentation/zz_constants.go new file mode 100644 index 0000000000..8e3f350876 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_constants.go @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +// BulletPointsEnum - This tests really long bullet points in enum documentation to see how wrapping and formatting are handled. +// This should wrap around correctly and maintain proper indentation for each line. +// - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points +// within documentation comments. It should properly indent the wrapped lines. +// - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved +// when the text wraps onto multiple lines in the generated documentation. +// - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping +// and formatting are correctly applied in the output. +// - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting +// and is long enough to test the wrapping behavior in such cases. +// - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold +// formatting is maintained across wrapped lines. +// - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic +// formatting is correctly applied even when the text spans multiple lines. +type BulletPointsEnum string + +const ( + // BulletPointsEnumBold - Bullet point with **bold text**. This line is intentionally long to test text wrapping in bullet + // points within enum documentation comments. It should properly indent the wrapped lines. + // - **One**: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. + // It should properly indent the wrapped lines. + // - **Two**: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. + // It should properly indent the wrapped lines. + BulletPointsEnumBold BulletPointsEnum = "Bold" + // BulletPointsEnumItalic - Bullet point with *italic text*. This line is intentionally long to test text wrapping in bullet + // points within enum documentation comments. It should properly indent the wrapped lines. + // - *One*: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. + // It should properly indent the wrapped lines. + // - *Two*: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. + // It should properly indent the wrapped lines. + BulletPointsEnumItalic BulletPointsEnum = "Italic" + // BulletPointsEnumSimple - Simple bullet point. This line is intentionally long to test text wrapping in bullet points within + // enum documentation comments. It should properly indent the wrapped lines. + // - One: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. + // It should properly indent the wrapped lines. + // - Two: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. + // It should properly indent the wrapped lines. + BulletPointsEnumSimple BulletPointsEnum = "Simple" +) + +// PossibleBulletPointsEnumValues returns the possible values for the BulletPointsEnum const type. +func PossibleBulletPointsEnumValues() []BulletPointsEnum { + return []BulletPointsEnum{ + BulletPointsEnumBold, + BulletPointsEnumItalic, + BulletPointsEnumSimple, + } +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_lists_client.go b/packages/typespec-go/test/http-specs/documentation/zz_lists_client.go new file mode 100644 index 0000000000..6a35b35cb7 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_lists_client.go @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// ListsClient contains the methods for the Lists group. +// Don't use this type directly, use [Client.NewListsClient] instead. +type ListsClient struct { + internal *azcore.Client + endpoint string +} + +// BulletPointsModel - +// If the operation fails it returns an *azcore.ResponseError type. +// - options - ListsClientBulletPointsModelOptions contains the optional parameters for the ListsClient.BulletPointsModel method. +func (client *ListsClient) BulletPointsModel(ctx context.Context, input BulletPointsModel, options *ListsClientBulletPointsModelOptions) (ListsClientBulletPointsModelResponse, error) { + var err error + const operationName = "ListsClient.BulletPointsModel" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.bulletPointsModelCreateRequest(ctx, input, options) + if err != nil { + return ListsClientBulletPointsModelResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ListsClientBulletPointsModelResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ListsClientBulletPointsModelResponse{}, err + } + return ListsClientBulletPointsModelResponse{}, nil +} + +// bulletPointsModelCreateRequest creates the BulletPointsModel request. +func (client *ListsClient) bulletPointsModelCreateRequest(ctx context.Context, input BulletPointsModel, _ *ListsClientBulletPointsModelOptions) (*policy.Request, error) { + urlPath := "/documentation/lists/bullet-points/model" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + body := struct { + Input BulletPointsModel `json:"input"` + }{ + Input: input, + } + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BulletPointsOp - This tests: +// - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points +// within documentation comments. It should properly indent the wrapped lines. +// - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved +// when the text wraps onto multiple lines in the generated documentation. +// - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping +// and formatting are correctly applied in the output. +// - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting +// and is long enough to test the wrapping behavior in such cases. +// - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold +// formatting is maintained across wrapped lines. +// - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic +// formatting is correctly applied even when the text spans multiple lines. +// If the operation fails it returns an *azcore.ResponseError type. +// - options - ListsClientBulletPointsOpOptions contains the optional parameters for the ListsClient.BulletPointsOp method. +func (client *ListsClient) BulletPointsOp(ctx context.Context, options *ListsClientBulletPointsOpOptions) (ListsClientBulletPointsOpResponse, error) { + var err error + const operationName = "ListsClient.BulletPointsOp" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.bulletPointsOpCreateRequest(ctx, options) + if err != nil { + return ListsClientBulletPointsOpResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ListsClientBulletPointsOpResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ListsClientBulletPointsOpResponse{}, err + } + return ListsClientBulletPointsOpResponse{}, nil +} + +// bulletPointsOpCreateRequest creates the BulletPointsOp request. +func (client *ListsClient) bulletPointsOpCreateRequest(ctx context.Context, _ *ListsClientBulletPointsOpOptions) (*policy.Request, error) { + urlPath := "/documentation/lists/bullet-points/op" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + return req, nil +} + +// Numbered - Steps to follow: +// 1. First step with **important** note +// 2. Second step with *emphasis* +// 3. Third step combining **bold** and *italic* +// 4. **Final step**: Review all steps for *accuracy*. +// If the operation fails it returns an *azcore.ResponseError type. +// - options - ListsClientNumberedOptions contains the optional parameters for the ListsClient.Numbered method. +func (client *ListsClient) Numbered(ctx context.Context, options *ListsClientNumberedOptions) (ListsClientNumberedResponse, error) { + var err error + const operationName = "ListsClient.Numbered" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.numberedCreateRequest(ctx, options) + if err != nil { + return ListsClientNumberedResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ListsClientNumberedResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ListsClientNumberedResponse{}, err + } + return ListsClientNumberedResponse{}, nil +} + +// numberedCreateRequest creates the Numbered request. +func (client *ListsClient) numberedCreateRequest(ctx context.Context, _ *ListsClientNumberedOptions) (*policy.Request, error) { + urlPath := "/documentation/lists/numbered" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + return req, nil +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_models.go b/packages/typespec-go/test/http-specs/documentation/zz_models.go new file mode 100644 index 0000000000..ee8385e594 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_models.go @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +// BulletPointsModel - This tests: +// - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points +// within documentation comments. It should properly indent the wrapped lines. +// - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved +// when the text wraps onto multiple lines in the generated documentation. +// - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping +// and formatting are correctly applied in the output. +// - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting +// and is long enough to test the wrapping behavior in such cases. +// - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold +// formatting is maintained across wrapped lines. +// - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic +// formatting is correctly applied even when the text spans multiple lines. +type BulletPointsModel struct { + // REQUIRED; This property uses an enum with bullet point documentation. The enum documentation includes various formatting + // styles to test rendering. The styles are: + // - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points + // within documentation comments. It should properly indent the wrapped lines. + // - Bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved + // when the text wraps onto multiple + // - Bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and + // formatting are correctly applied in the output. + // - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting + // and is long enough to test the wrapping behavior in such cases. + // - **Bold bullet point** + // - *Italic bullet point* + Prop *BulletPointsEnum +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_models_serde.go b/packages/typespec-go/test/http-specs/documentation/zz_models_serde.go new file mode 100644 index 0000000000..ed2cb8569a --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_models_serde.go @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type BulletPointsModel. +func (b BulletPointsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "prop", b.Prop) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BulletPointsModel. +func (b *BulletPointsModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "prop": + err = unpopulate(val, "Prop", &b.Prop) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_options.go b/packages/typespec-go/test/http-specs/documentation/zz_options.go new file mode 100644 index 0000000000..5df06ce8db --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_options.go @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +// ListsClientBulletPointsModelOptions contains the optional parameters for the ListsClient.BulletPointsModel method. +type ListsClientBulletPointsModelOptions struct { + // placeholder for future optional parameters +} + +// ListsClientBulletPointsOpOptions contains the optional parameters for the ListsClient.BulletPointsOp method. +type ListsClientBulletPointsOpOptions struct { + // placeholder for future optional parameters +} + +// ListsClientNumberedOptions contains the optional parameters for the ListsClient.Numbered method. +type ListsClientNumberedOptions struct { + // placeholder for future optional parameters +} + +// TextFormattingClientBoldTextOptions contains the optional parameters for the TextFormattingClient.BoldText method. +type TextFormattingClientBoldTextOptions struct { + // placeholder for future optional parameters +} + +// TextFormattingClientCombinedFormattingOptions contains the optional parameters for the TextFormattingClient.CombinedFormatting +// method. +type TextFormattingClientCombinedFormattingOptions struct { + // placeholder for future optional parameters +} + +// TextFormattingClientItalicTextOptions contains the optional parameters for the TextFormattingClient.ItalicText method. +type TextFormattingClientItalicTextOptions struct { + // placeholder for future optional parameters +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_responses.go b/packages/typespec-go/test/http-specs/documentation/zz_responses.go new file mode 100644 index 0000000000..fc3c802c3d --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_responses.go @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +// ListsClientBulletPointsModelResponse contains the response from method ListsClient.BulletPointsModel. +type ListsClientBulletPointsModelResponse struct { + // placeholder for future response values +} + +// ListsClientBulletPointsOpResponse contains the response from method ListsClient.BulletPointsOp. +type ListsClientBulletPointsOpResponse struct { + // placeholder for future response values +} + +// ListsClientNumberedResponse contains the response from method ListsClient.Numbered. +type ListsClientNumberedResponse struct { + // placeholder for future response values +} + +// TextFormattingClientBoldTextResponse contains the response from method TextFormattingClient.BoldText. +type TextFormattingClientBoldTextResponse struct { + // placeholder for future response values +} + +// TextFormattingClientCombinedFormattingResponse contains the response from method TextFormattingClient.CombinedFormatting. +type TextFormattingClientCombinedFormattingResponse struct { + // placeholder for future response values +} + +// TextFormattingClientItalicTextResponse contains the response from method TextFormattingClient.ItalicText. +type TextFormattingClientItalicTextResponse struct { + // placeholder for future response values +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go b/packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go new file mode 100644 index 0000000000..c9cf56b367 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentation + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// TextFormattingClient contains the methods for the TextFormatting group. +// Don't use this type directly, use [Client.NewTextFormattingClient] instead. +type TextFormattingClient struct { + internal *azcore.Client + endpoint string +} + +// BoldText - This is **bold text** in the middle of a sentence. +// This is a sentence with **multiple bold** sections and **another bold** section. +// **This entire sentence is bold.** +// If the operation fails it returns an *azcore.ResponseError type. +// - options - TextFormattingClientBoldTextOptions contains the optional parameters for the TextFormattingClient.BoldText method. +func (client *TextFormattingClient) BoldText(ctx context.Context, options *TextFormattingClientBoldTextOptions) (TextFormattingClientBoldTextResponse, error) { + var err error + const operationName = "TextFormattingClient.BoldText" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.boldTextCreateRequest(ctx, options) + if err != nil { + return TextFormattingClientBoldTextResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TextFormattingClientBoldTextResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TextFormattingClientBoldTextResponse{}, err + } + return TextFormattingClientBoldTextResponse{}, nil +} + +// boldTextCreateRequest creates the BoldText request. +func (client *TextFormattingClient) boldTextCreateRequest(ctx context.Context, _ *TextFormattingClientBoldTextOptions) (*policy.Request, error) { + urlPath := "/documentation/text-formatting/bold" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + return req, nil +} + +// CombinedFormatting - This sentence has **bold**, *italic*, and ***bold italic*** text. +// You can also combine them like **bold with *italic inside* bold**. +// Or *italic with **bold inside** italic*. +// This is a sentence with **bold**, *italic*, and ***bold italic*** text. +// If the operation fails it returns an *azcore.ResponseError type. +// - options - TextFormattingClientCombinedFormattingOptions contains the optional parameters for the TextFormattingClient.CombinedFormatting +// method. +func (client *TextFormattingClient) CombinedFormatting(ctx context.Context, options *TextFormattingClientCombinedFormattingOptions) (TextFormattingClientCombinedFormattingResponse, error) { + var err error + const operationName = "TextFormattingClient.CombinedFormatting" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.combinedFormattingCreateRequest(ctx, options) + if err != nil { + return TextFormattingClientCombinedFormattingResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TextFormattingClientCombinedFormattingResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TextFormattingClientCombinedFormattingResponse{}, err + } + return TextFormattingClientCombinedFormattingResponse{}, nil +} + +// combinedFormattingCreateRequest creates the CombinedFormatting request. +func (client *TextFormattingClient) combinedFormattingCreateRequest(ctx context.Context, _ *TextFormattingClientCombinedFormattingOptions) (*policy.Request, error) { + urlPath := "/documentation/text-formatting/combined" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + return req, nil +} + +// ItalicText - This is *italic text* in the middle of a sentence. +// This is a sentence with *multiple italic* sections and *another italic* section. +// *This entire sentence is italic.* +// If the operation fails it returns an *azcore.ResponseError type. +// - options - TextFormattingClientItalicTextOptions contains the optional parameters for the TextFormattingClient.ItalicText +// method. +func (client *TextFormattingClient) ItalicText(ctx context.Context, options *TextFormattingClientItalicTextOptions) (TextFormattingClientItalicTextResponse, error) { + var err error + const operationName = "TextFormattingClient.ItalicText" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.italicTextCreateRequest(ctx, options) + if err != nil { + return TextFormattingClientItalicTextResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TextFormattingClientItalicTextResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TextFormattingClientItalicTextResponse{}, err + } + return TextFormattingClientItalicTextResponse{}, nil +} + +// italicTextCreateRequest creates the ItalicText request. +func (client *TextFormattingClient) italicTextCreateRequest(ctx context.Context, _ *TextFormattingClientItalicTextOptions) (*policy.Request, error) { + urlPath := "/documentation/text-formatting/italic" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + return req, nil +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_version.go b/packages/typespec-go/test/http-specs/documentation/zz_version.go new file mode 100644 index 0000000000..92f4184e81 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentation/zz_version.go @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. + +package documentation + +const ( + moduleName = "documentation" + moduleVersion = "v0.1.0" +) From 6f75d92dc27872b37031fce068af79cb3c43e625 Mon Sep 17 00:00:00 2001 From: "judy.liu" Date: Fri, 30 Jan 2026 16:40:12 +0800 Subject: [PATCH 2/2] add code --- packages/typespec-go/.scripts/tspcompile.js | 2 +- .../documentation/fake/zz_server.go | 78 --------- .../fake/zz_textformatting_server.go | 155 ------------------ .../test/http-specs/documentation/go.mod | 11 -- .../http-specs/documentation/zz_client.go | 56 ------- .../http-specs/documentation/zz_options.go | 36 ---- .../http-specs/documentation/zz_responses.go | 35 ---- .../LICENSE.txt | 0 .../documentationlists_client_test.go | 37 +++++ ...documentationtextformatting_client_test.go | 36 ++++ .../fake/zz_documentation_server.go | 78 +++++++++ .../fake/zz_documentationlists_server.go} | 82 ++++----- .../zz_documentationtextformatting_server.go | 155 ++++++++++++++++++ .../fake/zz_internal.go | 0 .../test/http-specs/documentationgroup/go.mod | 17 ++ .../go.sum | 9 + .../testdata/_metadata.json | 0 .../zz_constants.go | 2 +- .../zz_documentation_client.go | 56 +++++++ .../zz_documentationlists_client.go} | 59 +++---- .../zz_documentationtextformatting_client.go} | 57 +++---- .../zz_models.go | 2 +- .../zz_models_serde.go | 2 +- .../documentationgroup/zz_options.go | 40 +++++ .../documentationgroup/zz_responses.go | 35 ++++ .../zz_version.go | 4 +- 26 files changed, 570 insertions(+), 474 deletions(-) delete mode 100644 packages/typespec-go/test/http-specs/documentation/fake/zz_server.go delete mode 100644 packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go delete mode 100644 packages/typespec-go/test/http-specs/documentation/go.mod delete mode 100644 packages/typespec-go/test/http-specs/documentation/zz_client.go delete mode 100644 packages/typespec-go/test/http-specs/documentation/zz_options.go delete mode 100644 packages/typespec-go/test/http-specs/documentation/zz_responses.go rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/LICENSE.txt (100%) create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/documentationlists_client_test.go create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/documentationtextformatting_client_test.go create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentation_server.go rename packages/typespec-go/test/http-specs/{documentation/fake/zz_lists_server.go => documentationgroup/fake/zz_documentationlists_server.go} (50%) create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationtextformatting_server.go rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/fake/zz_internal.go (100%) create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/go.mod rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/go.sum (63%) rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/testdata/_metadata.json (100%) rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/zz_constants.go (99%) create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/zz_documentation_client.go rename packages/typespec-go/test/http-specs/{documentation/zz_lists_client.go => documentationgroup/zz_documentationlists_client.go} (62%) rename packages/typespec-go/test/http-specs/{documentation/zz_textformatting_client.go => documentationgroup/zz_documentationtextformatting_client.go} (54%) rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/zz_models.go (98%) rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/zz_models_serde.go (98%) create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/zz_options.go create mode 100644 packages/typespec-go/test/http-specs/documentationgroup/zz_responses.go rename packages/typespec-go/test/http-specs/{documentation => documentationgroup}/zz_version.go (79%) diff --git a/packages/typespec-go/.scripts/tspcompile.js b/packages/typespec-go/.scripts/tspcompile.js index 24d68c28a2..1ffd0d9948 100644 --- a/packages/typespec-go/.scripts/tspcompile.js +++ b/packages/typespec-go/.scripts/tspcompile.js @@ -18,7 +18,7 @@ const compiler = pkgRoot + 'node_modules/@typespec/compiler/cmd/tsp.js'; // 'moduleName': [ 'input', 'emitter option 1', 'emitter option N...' ] // if no .tsp file is specified in input, it's assumed to be main.tsp const httpSpecsGroup = { - 'documentation': ['documentation'], + 'documentationgroup': ['documentation'], 'apikeygroup': ['authentication/api-key'], // ctors for API key not supported 'customgroup': ['authentication/http/custom'], // ctors for API key not supported 'oauth2group': ['authentication/oauth2'], diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_server.go b/packages/typespec-go/test/http-specs/documentation/fake/zz_server.go deleted file mode 100644 index 57ff16fe23..0000000000 --- a/packages/typespec-go/test/http-specs/documentation/fake/zz_server.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. - -package fake - -import ( - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "strings" - "sync" -) - -// Server is a fake server for instances of the documentation.Client type. -type Server struct { - // ListsServer contains the fakes for client ListsClient - ListsServer ListsServer - - // TextFormattingServer contains the fakes for client TextFormattingClient - TextFormattingServer TextFormattingServer -} - -// NewServerTransport creates a new instance of ServerTransport with the provided implementation. -// The returned ServerTransport instance is connected to an instance of documentation.Client via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewServerTransport(srv *Server) *ServerTransport { - return &ServerTransport{srv: srv} -} - -// ServerTransport connects instances of documentation.Client to instances of Server. -// Don't use this type directly, use NewServerTransport instead. -type ServerTransport struct { - srv *Server - trMu sync.Mutex - trListsServer *ListsServerTransport - trTextFormattingServer *TextFormattingServerTransport -} - -// Do implements the policy.Transporter interface for ServerTransport. -func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return s.dispatchToClientFake(req, method[:strings.Index(method, ".")]) -} - -func (s *ServerTransport) dispatchToClientFake(req *http.Request, client string) (*http.Response, error) { - var resp *http.Response - var err error - - switch client { - case "ListsClient": - initServer(&s.trMu, &s.trListsServer, func() *ListsServerTransport { - return NewListsServerTransport(&s.srv.ListsServer) - }) - resp, err = s.trListsServer.Do(req) - case "TextFormattingClient": - initServer(&s.trMu, &s.trTextFormattingServer, func() *TextFormattingServerTransport { - return NewTextFormattingServerTransport(&s.srv.TextFormattingServer) - }) - resp, err = s.trTextFormattingServer.Do(req) - default: - err = fmt.Errorf("unhandled client %s", client) - } - - return resp, err -} - -// set this to conditionally intercept incoming requests to ServerTransport -var serverTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go b/packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go deleted file mode 100644 index e7f324b4c2..0000000000 --- a/packages/typespec-go/test/http-specs/documentation/fake/zz_textformatting_server.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. - -package fake - -import ( - "context" - "documentation" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" -) - -// TextFormattingServer is a fake server for instances of the documentation.TextFormattingClient type. -type TextFormattingServer struct { - // BoldText is the fake for method TextFormattingClient.BoldText - // HTTP status codes to indicate success: http.StatusNoContent - BoldText func(ctx context.Context, options *documentation.TextFormattingClientBoldTextOptions) (resp azfake.Responder[documentation.TextFormattingClientBoldTextResponse], errResp azfake.ErrorResponder) - - // CombinedFormatting is the fake for method TextFormattingClient.CombinedFormatting - // HTTP status codes to indicate success: http.StatusNoContent - CombinedFormatting func(ctx context.Context, options *documentation.TextFormattingClientCombinedFormattingOptions) (resp azfake.Responder[documentation.TextFormattingClientCombinedFormattingResponse], errResp azfake.ErrorResponder) - - // ItalicText is the fake for method TextFormattingClient.ItalicText - // HTTP status codes to indicate success: http.StatusNoContent - ItalicText func(ctx context.Context, options *documentation.TextFormattingClientItalicTextOptions) (resp azfake.Responder[documentation.TextFormattingClientItalicTextResponse], errResp azfake.ErrorResponder) -} - -// NewTextFormattingServerTransport creates a new instance of TextFormattingServerTransport with the provided implementation. -// The returned TextFormattingServerTransport instance is connected to an instance of documentation.TextFormattingClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewTextFormattingServerTransport(srv *TextFormattingServer) *TextFormattingServerTransport { - return &TextFormattingServerTransport{srv: srv} -} - -// TextFormattingServerTransport connects instances of documentation.TextFormattingClient to instances of TextFormattingServer. -// Don't use this type directly, use NewTextFormattingServerTransport instead. -type TextFormattingServerTransport struct { - srv *TextFormattingServer -} - -// Do implements the policy.Transporter interface for TextFormattingServerTransport. -func (t *TextFormattingServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return t.dispatchToMethodFake(req, method) -} - -func (t *TextFormattingServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if textFormattingServerTransportInterceptor != nil { - res.resp, res.err, intercepted = textFormattingServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "TextFormattingClient.BoldText": - res.resp, res.err = t.dispatchBoldText(req) - case "TextFormattingClient.CombinedFormatting": - res.resp, res.err = t.dispatchCombinedFormatting(req) - case "TextFormattingClient.ItalicText": - res.resp, res.err = t.dispatchItalicText(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (t *TextFormattingServerTransport) dispatchBoldText(req *http.Request) (*http.Response, error) { - if t.srv.BoldText == nil { - return nil, &nonRetriableError{errors.New("fake for method BoldText not implemented")} - } - respr, errRespr := t.srv.BoldText(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (t *TextFormattingServerTransport) dispatchCombinedFormatting(req *http.Request) (*http.Response, error) { - if t.srv.CombinedFormatting == nil { - return nil, &nonRetriableError{errors.New("fake for method CombinedFormatting not implemented")} - } - respr, errRespr := t.srv.CombinedFormatting(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (t *TextFormattingServerTransport) dispatchItalicText(req *http.Request) (*http.Response, error) { - if t.srv.ItalicText == nil { - return nil, &nonRetriableError{errors.New("fake for method ItalicText not implemented")} - } - respr, errRespr := t.srv.ItalicText(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to TextFormattingServerTransport -var textFormattingServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/packages/typespec-go/test/http-specs/documentation/go.mod b/packages/typespec-go/test/http-specs/documentation/go.mod deleted file mode 100644 index f661fc2812..0000000000 --- a/packages/typespec-go/test/http-specs/documentation/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module documentation - -go 1.24.0 - -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 - -require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect - golang.org/x/net v0.49.0 // indirect - golang.org/x/text v0.33.0 // indirect -) diff --git a/packages/typespec-go/test/http-specs/documentation/zz_client.go b/packages/typespec-go/test/http-specs/documentation/zz_client.go deleted file mode 100644 index cf51104dfe..0000000000 --- a/packages/typespec-go/test/http-specs/documentation/zz_client.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. - -package documentation - -import ( - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" -) - -// Client - Illustrates documentation generation and formatting features -// Don't use this type directly, use NewClientWithNoCredential() instead. -type Client struct { - internal *azcore.Client - endpoint string -} - -// ClientOptions contains the optional values for creating a [Client]. -type ClientOptions struct { - azcore.ClientOptions -} - -// NewClientWithNoCredential creates a new instance of Client with the specified values. -// - endpoint - Service host -// - options - Contains optional client configuration. Pass nil to accept the default values. -func NewClientWithNoCredential(endpoint string, options *ClientOptions) (*Client, error) { - if options == nil { - options = &ClientOptions{} - } - cl, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions) - if err != nil { - return nil, err - } - client := &Client{ - endpoint: endpoint, - internal: cl, - } - return client, nil -} - -// NewListsClient creates a new instance of [ListsClient]. -func (client *Client) NewListsClient() *ListsClient { - return &ListsClient{ - endpoint: client.endpoint, - internal: client.internal, - } -} - -// NewTextFormattingClient creates a new instance of [TextFormattingClient]. -func (client *Client) NewTextFormattingClient() *TextFormattingClient { - return &TextFormattingClient{ - endpoint: client.endpoint, - internal: client.internal, - } -} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_options.go b/packages/typespec-go/test/http-specs/documentation/zz_options.go deleted file mode 100644 index 5df06ce8db..0000000000 --- a/packages/typespec-go/test/http-specs/documentation/zz_options.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. - -package documentation - -// ListsClientBulletPointsModelOptions contains the optional parameters for the ListsClient.BulletPointsModel method. -type ListsClientBulletPointsModelOptions struct { - // placeholder for future optional parameters -} - -// ListsClientBulletPointsOpOptions contains the optional parameters for the ListsClient.BulletPointsOp method. -type ListsClientBulletPointsOpOptions struct { - // placeholder for future optional parameters -} - -// ListsClientNumberedOptions contains the optional parameters for the ListsClient.Numbered method. -type ListsClientNumberedOptions struct { - // placeholder for future optional parameters -} - -// TextFormattingClientBoldTextOptions contains the optional parameters for the TextFormattingClient.BoldText method. -type TextFormattingClientBoldTextOptions struct { - // placeholder for future optional parameters -} - -// TextFormattingClientCombinedFormattingOptions contains the optional parameters for the TextFormattingClient.CombinedFormatting -// method. -type TextFormattingClientCombinedFormattingOptions struct { - // placeholder for future optional parameters -} - -// TextFormattingClientItalicTextOptions contains the optional parameters for the TextFormattingClient.ItalicText method. -type TextFormattingClientItalicTextOptions struct { - // placeholder for future optional parameters -} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_responses.go b/packages/typespec-go/test/http-specs/documentation/zz_responses.go deleted file mode 100644 index fc3c802c3d..0000000000 --- a/packages/typespec-go/test/http-specs/documentation/zz_responses.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. - -package documentation - -// ListsClientBulletPointsModelResponse contains the response from method ListsClient.BulletPointsModel. -type ListsClientBulletPointsModelResponse struct { - // placeholder for future response values -} - -// ListsClientBulletPointsOpResponse contains the response from method ListsClient.BulletPointsOp. -type ListsClientBulletPointsOpResponse struct { - // placeholder for future response values -} - -// ListsClientNumberedResponse contains the response from method ListsClient.Numbered. -type ListsClientNumberedResponse struct { - // placeholder for future response values -} - -// TextFormattingClientBoldTextResponse contains the response from method TextFormattingClient.BoldText. -type TextFormattingClientBoldTextResponse struct { - // placeholder for future response values -} - -// TextFormattingClientCombinedFormattingResponse contains the response from method TextFormattingClient.CombinedFormatting. -type TextFormattingClientCombinedFormattingResponse struct { - // placeholder for future response values -} - -// TextFormattingClientItalicTextResponse contains the response from method TextFormattingClient.ItalicText. -type TextFormattingClientItalicTextResponse struct { - // placeholder for future response values -} diff --git a/packages/typespec-go/test/http-specs/documentation/LICENSE.txt b/packages/typespec-go/test/http-specs/documentationgroup/LICENSE.txt similarity index 100% rename from packages/typespec-go/test/http-specs/documentation/LICENSE.txt rename to packages/typespec-go/test/http-specs/documentationgroup/LICENSE.txt diff --git a/packages/typespec-go/test/http-specs/documentationgroup/documentationlists_client_test.go b/packages/typespec-go/test/http-specs/documentationgroup/documentationlists_client_test.go new file mode 100644 index 0000000000..48975d799b --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/documentationlists_client_test.go @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package documentationgroup_test + +import ( + "context" + "documentationgroup" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestListsClient_BulletPointsModel(t *testing.T) { + client, err := documentationgroup.NewDocumentationClientWithNoCredential("http://localhost:3000", nil) + require.NoError(t, err) + enumValue := documentationgroup.BulletPointsEnum("Simple") + resp, err := client.NewDocumentationListsClient().BulletPointsModel(context.Background(), documentationgroup.BulletPointsModel{Prop: &enumValue}, nil) + require.NoError(t, err) + require.Zero(t, resp) +} + +func TestListsClient_Numbered(t *testing.T) { + client, err := documentationgroup.NewDocumentationClientWithNoCredential("http://localhost:3000", nil) + require.NoError(t, err) + resp, err := client.NewDocumentationListsClient().Numbered(context.Background(), nil) + require.NoError(t, err) + require.Zero(t, resp) +} + +func TestListsClient_BulletPointsOp(t *testing.T) { + client, err := documentationgroup.NewDocumentationClientWithNoCredential("http://localhost:3000", nil) + require.NoError(t, err) + resp, err := client.NewDocumentationListsClient().BulletPointsOp(context.Background(), nil) + require.NoError(t, err) + require.Zero(t, resp) +} diff --git a/packages/typespec-go/test/http-specs/documentationgroup/documentationtextformatting_client_test.go b/packages/typespec-go/test/http-specs/documentationgroup/documentationtextformatting_client_test.go new file mode 100644 index 0000000000..dd561b8606 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/documentationtextformatting_client_test.go @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package documentationgroup_test + +import ( + "context" + "documentationgroup" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestTextFormattingClient_BoldText(t *testing.T) { + client, err := documentationgroup.NewDocumentationClientWithNoCredential("http://localhost:3000", nil) + require.NoError(t, err) + resp, err := client.NewDocumentationTextFormattingClient().BoldText(context.Background(), nil) + require.NoError(t, err) + require.Zero(t, resp) +} + +func TestTextFormattingClient_CombinedFormatting(t *testing.T) { + client, err := documentationgroup.NewDocumentationClientWithNoCredential("http://localhost:3000", nil) + require.NoError(t, err) + resp, err := client.NewDocumentationTextFormattingClient().CombinedFormatting(context.Background(), nil) + require.NoError(t, err) + require.Zero(t, resp) +} + +func TestTextFormattingClient_ItalicText(t *testing.T) { + client, err := documentationgroup.NewDocumentationClientWithNoCredential("http://localhost:3000", nil) + require.NoError(t, err) + resp, err := client.NewDocumentationTextFormattingClient().ItalicText(context.Background(), nil) + require.NoError(t, err) + require.Zero(t, resp) +} diff --git a/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentation_server.go b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentation_server.go new file mode 100644 index 0000000000..f2841ecbc1 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentation_server.go @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// DocumentationServer is a fake server for instances of the documentationgroup.DocumentationClient type. +type DocumentationServer struct { + // DocumentationListsServer contains the fakes for client DocumentationListsClient + DocumentationListsServer DocumentationListsServer + + // DocumentationTextFormattingServer contains the fakes for client DocumentationTextFormattingClient + DocumentationTextFormattingServer DocumentationTextFormattingServer +} + +// NewDocumentationServerTransport creates a new instance of DocumentationServerTransport with the provided implementation. +// The returned DocumentationServerTransport instance is connected to an instance of documentationgroup.DocumentationClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDocumentationServerTransport(srv *DocumentationServer) *DocumentationServerTransport { + return &DocumentationServerTransport{srv: srv} +} + +// DocumentationServerTransport connects instances of documentationgroup.DocumentationClient to instances of DocumentationServer. +// Don't use this type directly, use NewDocumentationServerTransport instead. +type DocumentationServerTransport struct { + srv *DocumentationServer + trMu sync.Mutex + trDocumentationListsServer *DocumentationListsServerTransport + trDocumentationTextFormattingServer *DocumentationTextFormattingServerTransport +} + +// Do implements the policy.Transporter interface for DocumentationServerTransport. +func (d *DocumentationServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return d.dispatchToClientFake(req, method[:strings.Index(method, ".")]) +} + +func (d *DocumentationServerTransport) dispatchToClientFake(req *http.Request, client string) (*http.Response, error) { + var resp *http.Response + var err error + + switch client { + case "DocumentationListsClient": + initServer(&d.trMu, &d.trDocumentationListsServer, func() *DocumentationListsServerTransport { + return NewDocumentationListsServerTransport(&d.srv.DocumentationListsServer) + }) + resp, err = d.trDocumentationListsServer.Do(req) + case "DocumentationTextFormattingClient": + initServer(&d.trMu, &d.trDocumentationTextFormattingServer, func() *DocumentationTextFormattingServerTransport { + return NewDocumentationTextFormattingServerTransport(&d.srv.DocumentationTextFormattingServer) + }) + resp, err = d.trDocumentationTextFormattingServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + return resp, err +} + +// set this to conditionally intercept incoming requests to DocumentationServerTransport +var documentationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationlists_server.go similarity index 50% rename from packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go rename to packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationlists_server.go index 4e39a784c4..b917a4c79e 100644 --- a/packages/typespec-go/test/http-specs/documentation/fake/zz_lists_server.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationlists_server.go @@ -6,7 +6,7 @@ package fake import ( "context" - "documentation" + "documentationgroup" "errors" "fmt" azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" @@ -15,63 +15,63 @@ import ( "net/http" ) -// ListsServer is a fake server for instances of the documentation.ListsClient type. -type ListsServer struct { - // BulletPointsModel is the fake for method ListsClient.BulletPointsModel +// DocumentationListsServer is a fake server for instances of the documentationgroup.DocumentationListsClient type. +type DocumentationListsServer struct { + // BulletPointsModel is the fake for method DocumentationListsClient.BulletPointsModel // HTTP status codes to indicate success: http.StatusOK - BulletPointsModel func(ctx context.Context, input documentation.BulletPointsModel, options *documentation.ListsClientBulletPointsModelOptions) (resp azfake.Responder[documentation.ListsClientBulletPointsModelResponse], errResp azfake.ErrorResponder) + BulletPointsModel func(ctx context.Context, input documentationgroup.BulletPointsModel, options *documentationgroup.DocumentationListsClientBulletPointsModelOptions) (resp azfake.Responder[documentationgroup.DocumentationListsClientBulletPointsModelResponse], errResp azfake.ErrorResponder) - // BulletPointsOp is the fake for method ListsClient.BulletPointsOp + // BulletPointsOp is the fake for method DocumentationListsClient.BulletPointsOp // HTTP status codes to indicate success: http.StatusNoContent - BulletPointsOp func(ctx context.Context, options *documentation.ListsClientBulletPointsOpOptions) (resp azfake.Responder[documentation.ListsClientBulletPointsOpResponse], errResp azfake.ErrorResponder) + BulletPointsOp func(ctx context.Context, options *documentationgroup.DocumentationListsClientBulletPointsOpOptions) (resp azfake.Responder[documentationgroup.DocumentationListsClientBulletPointsOpResponse], errResp azfake.ErrorResponder) - // Numbered is the fake for method ListsClient.Numbered + // Numbered is the fake for method DocumentationListsClient.Numbered // HTTP status codes to indicate success: http.StatusNoContent - Numbered func(ctx context.Context, options *documentation.ListsClientNumberedOptions) (resp azfake.Responder[documentation.ListsClientNumberedResponse], errResp azfake.ErrorResponder) + Numbered func(ctx context.Context, options *documentationgroup.DocumentationListsClientNumberedOptions) (resp azfake.Responder[documentationgroup.DocumentationListsClientNumberedResponse], errResp azfake.ErrorResponder) } -// NewListsServerTransport creates a new instance of ListsServerTransport with the provided implementation. -// The returned ListsServerTransport instance is connected to an instance of documentation.ListsClient via the +// NewDocumentationListsServerTransport creates a new instance of DocumentationListsServerTransport with the provided implementation. +// The returned DocumentationListsServerTransport instance is connected to an instance of documentationgroup.DocumentationListsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewListsServerTransport(srv *ListsServer) *ListsServerTransport { - return &ListsServerTransport{srv: srv} +func NewDocumentationListsServerTransport(srv *DocumentationListsServer) *DocumentationListsServerTransport { + return &DocumentationListsServerTransport{srv: srv} } -// ListsServerTransport connects instances of documentation.ListsClient to instances of ListsServer. -// Don't use this type directly, use NewListsServerTransport instead. -type ListsServerTransport struct { - srv *ListsServer +// DocumentationListsServerTransport connects instances of documentationgroup.DocumentationListsClient to instances of DocumentationListsServer. +// Don't use this type directly, use NewDocumentationListsServerTransport instead. +type DocumentationListsServerTransport struct { + srv *DocumentationListsServer } -// Do implements the policy.Transporter interface for ListsServerTransport. -func (l *ListsServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for DocumentationListsServerTransport. +func (d *DocumentationListsServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - return l.dispatchToMethodFake(req, method) + return d.dispatchToMethodFake(req, method) } -func (l *ListsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { +func (d *DocumentationListsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { resultChan := make(chan result) defer close(resultChan) go func() { var intercepted bool var res result - if listsServerTransportInterceptor != nil { - res.resp, res.err, intercepted = listsServerTransportInterceptor.Do(req) + if documentationListsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = documentationListsServerTransportInterceptor.Do(req) } if !intercepted { switch method { - case "ListsClient.BulletPointsModel": - res.resp, res.err = l.dispatchBulletPointsModel(req) - case "ListsClient.BulletPointsOp": - res.resp, res.err = l.dispatchBulletPointsOp(req) - case "ListsClient.Numbered": - res.resp, res.err = l.dispatchNumbered(req) + case "DocumentationListsClient.BulletPointsModel": + res.resp, res.err = d.dispatchBulletPointsModel(req) + case "DocumentationListsClient.BulletPointsOp": + res.resp, res.err = d.dispatchBulletPointsOp(req) + case "DocumentationListsClient.Numbered": + res.resp, res.err = d.dispatchNumbered(req) default: res.err = fmt.Errorf("unhandled API %s", method) } @@ -91,18 +91,18 @@ func (l *ListsServerTransport) dispatchToMethodFake(req *http.Request, method st } } -func (l *ListsServerTransport) dispatchBulletPointsModel(req *http.Request) (*http.Response, error) { - if l.srv.BulletPointsModel == nil { +func (d *DocumentationListsServerTransport) dispatchBulletPointsModel(req *http.Request) (*http.Response, error) { + if d.srv.BulletPointsModel == nil { return nil, &nonRetriableError{errors.New("fake for method BulletPointsModel not implemented")} } type partialBodyParams struct { - Input documentation.BulletPointsModel `json:"input"` + Input documentationgroup.BulletPointsModel `json:"input"` } body, err := server.UnmarshalRequestAsJSON[partialBodyParams](req) if err != nil { return nil, err } - respr, errRespr := l.srv.BulletPointsModel(req.Context(), body.Input, nil) + respr, errRespr := d.srv.BulletPointsModel(req.Context(), body.Input, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -117,11 +117,11 @@ func (l *ListsServerTransport) dispatchBulletPointsModel(req *http.Request) (*ht return resp, nil } -func (l *ListsServerTransport) dispatchBulletPointsOp(req *http.Request) (*http.Response, error) { - if l.srv.BulletPointsOp == nil { +func (d *DocumentationListsServerTransport) dispatchBulletPointsOp(req *http.Request) (*http.Response, error) { + if d.srv.BulletPointsOp == nil { return nil, &nonRetriableError{errors.New("fake for method BulletPointsOp not implemented")} } - respr, errRespr := l.srv.BulletPointsOp(req.Context(), nil) + respr, errRespr := d.srv.BulletPointsOp(req.Context(), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -136,11 +136,11 @@ func (l *ListsServerTransport) dispatchBulletPointsOp(req *http.Request) (*http. return resp, nil } -func (l *ListsServerTransport) dispatchNumbered(req *http.Request) (*http.Response, error) { - if l.srv.Numbered == nil { +func (d *DocumentationListsServerTransport) dispatchNumbered(req *http.Request) (*http.Response, error) { + if d.srv.Numbered == nil { return nil, &nonRetriableError{errors.New("fake for method Numbered not implemented")} } - respr, errRespr := l.srv.Numbered(req.Context(), nil) + respr, errRespr := d.srv.Numbered(req.Context(), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -155,8 +155,8 @@ func (l *ListsServerTransport) dispatchNumbered(req *http.Request) (*http.Respon return resp, nil } -// set this to conditionally intercept incoming requests to ListsServerTransport -var listsServerTransportInterceptor interface { +// set this to conditionally intercept incoming requests to DocumentationListsServerTransport +var documentationListsServerTransportInterceptor interface { // Do returns true if the server transport should use the returned response/error Do(*http.Request) (*http.Response, error, bool) } diff --git a/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationtextformatting_server.go b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationtextformatting_server.go new file mode 100644 index 0000000000..edce77ee17 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_documentationtextformatting_server.go @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "documentationgroup" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// DocumentationTextFormattingServer is a fake server for instances of the documentationgroup.DocumentationTextFormattingClient type. +type DocumentationTextFormattingServer struct { + // BoldText is the fake for method DocumentationTextFormattingClient.BoldText + // HTTP status codes to indicate success: http.StatusNoContent + BoldText func(ctx context.Context, options *documentationgroup.DocumentationTextFormattingClientBoldTextOptions) (resp azfake.Responder[documentationgroup.DocumentationTextFormattingClientBoldTextResponse], errResp azfake.ErrorResponder) + + // CombinedFormatting is the fake for method DocumentationTextFormattingClient.CombinedFormatting + // HTTP status codes to indicate success: http.StatusNoContent + CombinedFormatting func(ctx context.Context, options *documentationgroup.DocumentationTextFormattingClientCombinedFormattingOptions) (resp azfake.Responder[documentationgroup.DocumentationTextFormattingClientCombinedFormattingResponse], errResp azfake.ErrorResponder) + + // ItalicText is the fake for method DocumentationTextFormattingClient.ItalicText + // HTTP status codes to indicate success: http.StatusNoContent + ItalicText func(ctx context.Context, options *documentationgroup.DocumentationTextFormattingClientItalicTextOptions) (resp azfake.Responder[documentationgroup.DocumentationTextFormattingClientItalicTextResponse], errResp azfake.ErrorResponder) +} + +// NewDocumentationTextFormattingServerTransport creates a new instance of DocumentationTextFormattingServerTransport with the provided implementation. +// The returned DocumentationTextFormattingServerTransport instance is connected to an instance of documentationgroup.DocumentationTextFormattingClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDocumentationTextFormattingServerTransport(srv *DocumentationTextFormattingServer) *DocumentationTextFormattingServerTransport { + return &DocumentationTextFormattingServerTransport{srv: srv} +} + +// DocumentationTextFormattingServerTransport connects instances of documentationgroup.DocumentationTextFormattingClient to instances of DocumentationTextFormattingServer. +// Don't use this type directly, use NewDocumentationTextFormattingServerTransport instead. +type DocumentationTextFormattingServerTransport struct { + srv *DocumentationTextFormattingServer +} + +// Do implements the policy.Transporter interface for DocumentationTextFormattingServerTransport. +func (d *DocumentationTextFormattingServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return d.dispatchToMethodFake(req, method) +} + +func (d *DocumentationTextFormattingServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if documentationTextFormattingServerTransportInterceptor != nil { + res.resp, res.err, intercepted = documentationTextFormattingServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DocumentationTextFormattingClient.BoldText": + res.resp, res.err = d.dispatchBoldText(req) + case "DocumentationTextFormattingClient.CombinedFormatting": + res.resp, res.err = d.dispatchCombinedFormatting(req) + case "DocumentationTextFormattingClient.ItalicText": + res.resp, res.err = d.dispatchItalicText(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (d *DocumentationTextFormattingServerTransport) dispatchBoldText(req *http.Request) (*http.Response, error) { + if d.srv.BoldText == nil { + return nil, &nonRetriableError{errors.New("fake for method BoldText not implemented")} + } + respr, errRespr := d.srv.BoldText(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DocumentationTextFormattingServerTransport) dispatchCombinedFormatting(req *http.Request) (*http.Response, error) { + if d.srv.CombinedFormatting == nil { + return nil, &nonRetriableError{errors.New("fake for method CombinedFormatting not implemented")} + } + respr, errRespr := d.srv.CombinedFormatting(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DocumentationTextFormattingServerTransport) dispatchItalicText(req *http.Request) (*http.Response, error) { + if d.srv.ItalicText == nil { + return nil, &nonRetriableError{errors.New("fake for method ItalicText not implemented")} + } + respr, errRespr := d.srv.ItalicText(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to DocumentationTextFormattingServerTransport +var documentationTextFormattingServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/packages/typespec-go/test/http-specs/documentation/fake/zz_internal.go b/packages/typespec-go/test/http-specs/documentationgroup/fake/zz_internal.go similarity index 100% rename from packages/typespec-go/test/http-specs/documentation/fake/zz_internal.go rename to packages/typespec-go/test/http-specs/documentationgroup/fake/zz_internal.go diff --git a/packages/typespec-go/test/http-specs/documentationgroup/go.mod b/packages/typespec-go/test/http-specs/documentationgroup/go.mod new file mode 100644 index 0000000000..216bc4f326 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/go.mod @@ -0,0 +1,17 @@ +module documentationgroup + +go 1.24.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 + github.com/stretchr/testify v1.11.1 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/net v0.49.0 // indirect + golang.org/x/text v0.33.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/packages/typespec-go/test/http-specs/documentation/go.sum b/packages/typespec-go/test/http-specs/documentationgroup/go.sum similarity index 63% rename from packages/typespec-go/test/http-specs/documentation/go.sum rename to packages/typespec-go/test/http-specs/documentationgroup/go.sum index 84a581b2cc..104d7f8220 100644 --- a/packages/typespec-go/test/http-specs/documentation/go.sum +++ b/packages/typespec-go/test/http-specs/documentationgroup/go.sum @@ -4,13 +4,22 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDo github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/packages/typespec-go/test/http-specs/documentation/testdata/_metadata.json b/packages/typespec-go/test/http-specs/documentationgroup/testdata/_metadata.json similarity index 100% rename from packages/typespec-go/test/http-specs/documentation/testdata/_metadata.json rename to packages/typespec-go/test/http-specs/documentationgroup/testdata/_metadata.json diff --git a/packages/typespec-go/test/http-specs/documentation/zz_constants.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_constants.go similarity index 99% rename from packages/typespec-go/test/http-specs/documentation/zz_constants.go rename to packages/typespec-go/test/http-specs/documentationgroup/zz_constants.go index 8e3f350876..d1b19de042 100644 --- a/packages/typespec-go/test/http-specs/documentation/zz_constants.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_constants.go @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package documentation +package documentationgroup // BulletPointsEnum - This tests really long bullet points in enum documentation to see how wrapping and formatting are handled. // This should wrap around correctly and maintain proper indentation for each line. diff --git a/packages/typespec-go/test/http-specs/documentationgroup/zz_documentation_client.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_documentation_client.go new file mode 100644 index 0000000000..4f158b1fea --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_documentation_client.go @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentationgroup + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// DocumentationClient - Illustrates documentation generation and formatting features +// Don't use this type directly, use NewDocumentationClientWithNoCredential() instead. +type DocumentationClient struct { + internal *azcore.Client + endpoint string +} + +// DocumentationClientOptions contains the optional values for creating a [DocumentationClient]. +type DocumentationClientOptions struct { + azcore.ClientOptions +} + +// NewDocumentationClientWithNoCredential creates a new instance of DocumentationClient with the specified values. +// - endpoint - Service host +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewDocumentationClientWithNoCredential(endpoint string, options *DocumentationClientOptions) (*DocumentationClient, error) { + if options == nil { + options = &DocumentationClientOptions{} + } + cl, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions) + if err != nil { + return nil, err + } + client := &DocumentationClient{ + endpoint: endpoint, + internal: cl, + } + return client, nil +} + +// NewDocumentationListsClient creates a new instance of [DocumentationListsClient]. +func (client *DocumentationClient) NewDocumentationListsClient() *DocumentationListsClient { + return &DocumentationListsClient{ + endpoint: client.endpoint, + internal: client.internal, + } +} + +// NewDocumentationTextFormattingClient creates a new instance of [DocumentationTextFormattingClient]. +func (client *DocumentationClient) NewDocumentationTextFormattingClient() *DocumentationTextFormattingClient { + return &DocumentationTextFormattingClient{ + endpoint: client.endpoint, + internal: client.internal, + } +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_lists_client.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_documentationlists_client.go similarity index 62% rename from packages/typespec-go/test/http-specs/documentation/zz_lists_client.go rename to packages/typespec-go/test/http-specs/documentationgroup/zz_documentationlists_client.go index 6a35b35cb7..9bd25c76b9 100644 --- a/packages/typespec-go/test/http-specs/documentation/zz_lists_client.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_documentationlists_client.go @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package documentation +package documentationgroup import ( "context" @@ -12,39 +12,40 @@ import ( "net/http" ) -// ListsClient contains the methods for the Lists group. -// Don't use this type directly, use [Client.NewListsClient] instead. -type ListsClient struct { +// DocumentationListsClient contains the methods for the DocumentationLists group. +// Don't use this type directly, use [DocumentationClient.NewDocumentationListsClient] instead. +type DocumentationListsClient struct { internal *azcore.Client endpoint string } // BulletPointsModel - // If the operation fails it returns an *azcore.ResponseError type. -// - options - ListsClientBulletPointsModelOptions contains the optional parameters for the ListsClient.BulletPointsModel method. -func (client *ListsClient) BulletPointsModel(ctx context.Context, input BulletPointsModel, options *ListsClientBulletPointsModelOptions) (ListsClientBulletPointsModelResponse, error) { +// - options - DocumentationListsClientBulletPointsModelOptions contains the optional parameters for the DocumentationListsClient.BulletPointsModel +// method. +func (client *DocumentationListsClient) BulletPointsModel(ctx context.Context, input BulletPointsModel, options *DocumentationListsClientBulletPointsModelOptions) (DocumentationListsClientBulletPointsModelResponse, error) { var err error - const operationName = "ListsClient.BulletPointsModel" + const operationName = "DocumentationListsClient.BulletPointsModel" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.bulletPointsModelCreateRequest(ctx, input, options) if err != nil { - return ListsClientBulletPointsModelResponse{}, err + return DocumentationListsClientBulletPointsModelResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ListsClientBulletPointsModelResponse{}, err + return DocumentationListsClientBulletPointsModelResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return ListsClientBulletPointsModelResponse{}, err + return DocumentationListsClientBulletPointsModelResponse{}, err } - return ListsClientBulletPointsModelResponse{}, nil + return DocumentationListsClientBulletPointsModelResponse{}, nil } // bulletPointsModelCreateRequest creates the BulletPointsModel request. -func (client *ListsClient) bulletPointsModelCreateRequest(ctx context.Context, input BulletPointsModel, _ *ListsClientBulletPointsModelOptions) (*policy.Request, error) { +func (client *DocumentationListsClient) bulletPointsModelCreateRequest(ctx context.Context, input BulletPointsModel, _ *DocumentationListsClientBulletPointsModelOptions) (*policy.Request, error) { urlPath := "/documentation/lists/bullet-points/model" req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { @@ -76,30 +77,31 @@ func (client *ListsClient) bulletPointsModelCreateRequest(ctx context.Context, i // - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic // formatting is correctly applied even when the text spans multiple lines. // If the operation fails it returns an *azcore.ResponseError type. -// - options - ListsClientBulletPointsOpOptions contains the optional parameters for the ListsClient.BulletPointsOp method. -func (client *ListsClient) BulletPointsOp(ctx context.Context, options *ListsClientBulletPointsOpOptions) (ListsClientBulletPointsOpResponse, error) { +// - options - DocumentationListsClientBulletPointsOpOptions contains the optional parameters for the DocumentationListsClient.BulletPointsOp +// method. +func (client *DocumentationListsClient) BulletPointsOp(ctx context.Context, options *DocumentationListsClientBulletPointsOpOptions) (DocumentationListsClientBulletPointsOpResponse, error) { var err error - const operationName = "ListsClient.BulletPointsOp" + const operationName = "DocumentationListsClient.BulletPointsOp" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.bulletPointsOpCreateRequest(ctx, options) if err != nil { - return ListsClientBulletPointsOpResponse{}, err + return DocumentationListsClientBulletPointsOpResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ListsClientBulletPointsOpResponse{}, err + return DocumentationListsClientBulletPointsOpResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return ListsClientBulletPointsOpResponse{}, err + return DocumentationListsClientBulletPointsOpResponse{}, err } - return ListsClientBulletPointsOpResponse{}, nil + return DocumentationListsClientBulletPointsOpResponse{}, nil } // bulletPointsOpCreateRequest creates the BulletPointsOp request. -func (client *ListsClient) bulletPointsOpCreateRequest(ctx context.Context, _ *ListsClientBulletPointsOpOptions) (*policy.Request, error) { +func (client *DocumentationListsClient) bulletPointsOpCreateRequest(ctx context.Context, _ *DocumentationListsClientBulletPointsOpOptions) (*policy.Request, error) { urlPath := "/documentation/lists/bullet-points/op" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { @@ -114,30 +116,31 @@ func (client *ListsClient) bulletPointsOpCreateRequest(ctx context.Context, _ *L // 3. Third step combining **bold** and *italic* // 4. **Final step**: Review all steps for *accuracy*. // If the operation fails it returns an *azcore.ResponseError type. -// - options - ListsClientNumberedOptions contains the optional parameters for the ListsClient.Numbered method. -func (client *ListsClient) Numbered(ctx context.Context, options *ListsClientNumberedOptions) (ListsClientNumberedResponse, error) { +// - options - DocumentationListsClientNumberedOptions contains the optional parameters for the DocumentationListsClient.Numbered +// method. +func (client *DocumentationListsClient) Numbered(ctx context.Context, options *DocumentationListsClientNumberedOptions) (DocumentationListsClientNumberedResponse, error) { var err error - const operationName = "ListsClient.Numbered" + const operationName = "DocumentationListsClient.Numbered" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.numberedCreateRequest(ctx, options) if err != nil { - return ListsClientNumberedResponse{}, err + return DocumentationListsClientNumberedResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ListsClientNumberedResponse{}, err + return DocumentationListsClientNumberedResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return ListsClientNumberedResponse{}, err + return DocumentationListsClientNumberedResponse{}, err } - return ListsClientNumberedResponse{}, nil + return DocumentationListsClientNumberedResponse{}, nil } // numberedCreateRequest creates the Numbered request. -func (client *ListsClient) numberedCreateRequest(ctx context.Context, _ *ListsClientNumberedOptions) (*policy.Request, error) { +func (client *DocumentationListsClient) numberedCreateRequest(ctx context.Context, _ *DocumentationListsClientNumberedOptions) (*policy.Request, error) { urlPath := "/documentation/lists/numbered" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { diff --git a/packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_documentationtextformatting_client.go similarity index 54% rename from packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go rename to packages/typespec-go/test/http-specs/documentationgroup/zz_documentationtextformatting_client.go index c9cf56b367..b612a6738c 100644 --- a/packages/typespec-go/test/http-specs/documentation/zz_textformatting_client.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_documentationtextformatting_client.go @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package documentation +package documentationgroup import ( "context" @@ -12,9 +12,9 @@ import ( "net/http" ) -// TextFormattingClient contains the methods for the TextFormatting group. -// Don't use this type directly, use [Client.NewTextFormattingClient] instead. -type TextFormattingClient struct { +// DocumentationTextFormattingClient contains the methods for the DocumentationTextFormatting group. +// Don't use this type directly, use [DocumentationClient.NewDocumentationTextFormattingClient] instead. +type DocumentationTextFormattingClient struct { internal *azcore.Client endpoint string } @@ -23,30 +23,31 @@ type TextFormattingClient struct { // This is a sentence with **multiple bold** sections and **another bold** section. // **This entire sentence is bold.** // If the operation fails it returns an *azcore.ResponseError type. -// - options - TextFormattingClientBoldTextOptions contains the optional parameters for the TextFormattingClient.BoldText method. -func (client *TextFormattingClient) BoldText(ctx context.Context, options *TextFormattingClientBoldTextOptions) (TextFormattingClientBoldTextResponse, error) { +// - options - DocumentationTextFormattingClientBoldTextOptions contains the optional parameters for the DocumentationTextFormattingClient.BoldText +// method. +func (client *DocumentationTextFormattingClient) BoldText(ctx context.Context, options *DocumentationTextFormattingClientBoldTextOptions) (DocumentationTextFormattingClientBoldTextResponse, error) { var err error - const operationName = "TextFormattingClient.BoldText" + const operationName = "DocumentationTextFormattingClient.BoldText" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.boldTextCreateRequest(ctx, options) if err != nil { - return TextFormattingClientBoldTextResponse{}, err + return DocumentationTextFormattingClientBoldTextResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TextFormattingClientBoldTextResponse{}, err + return DocumentationTextFormattingClientBoldTextResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return TextFormattingClientBoldTextResponse{}, err + return DocumentationTextFormattingClientBoldTextResponse{}, err } - return TextFormattingClientBoldTextResponse{}, nil + return DocumentationTextFormattingClientBoldTextResponse{}, nil } // boldTextCreateRequest creates the BoldText request. -func (client *TextFormattingClient) boldTextCreateRequest(ctx context.Context, _ *TextFormattingClientBoldTextOptions) (*policy.Request, error) { +func (client *DocumentationTextFormattingClient) boldTextCreateRequest(ctx context.Context, _ *DocumentationTextFormattingClientBoldTextOptions) (*policy.Request, error) { urlPath := "/documentation/text-formatting/bold" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { @@ -60,31 +61,31 @@ func (client *TextFormattingClient) boldTextCreateRequest(ctx context.Context, _ // Or *italic with **bold inside** italic*. // This is a sentence with **bold**, *italic*, and ***bold italic*** text. // If the operation fails it returns an *azcore.ResponseError type. -// - options - TextFormattingClientCombinedFormattingOptions contains the optional parameters for the TextFormattingClient.CombinedFormatting +// - options - DocumentationTextFormattingClientCombinedFormattingOptions contains the optional parameters for the DocumentationTextFormattingClient.CombinedFormatting // method. -func (client *TextFormattingClient) CombinedFormatting(ctx context.Context, options *TextFormattingClientCombinedFormattingOptions) (TextFormattingClientCombinedFormattingResponse, error) { +func (client *DocumentationTextFormattingClient) CombinedFormatting(ctx context.Context, options *DocumentationTextFormattingClientCombinedFormattingOptions) (DocumentationTextFormattingClientCombinedFormattingResponse, error) { var err error - const operationName = "TextFormattingClient.CombinedFormatting" + const operationName = "DocumentationTextFormattingClient.CombinedFormatting" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.combinedFormattingCreateRequest(ctx, options) if err != nil { - return TextFormattingClientCombinedFormattingResponse{}, err + return DocumentationTextFormattingClientCombinedFormattingResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TextFormattingClientCombinedFormattingResponse{}, err + return DocumentationTextFormattingClientCombinedFormattingResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return TextFormattingClientCombinedFormattingResponse{}, err + return DocumentationTextFormattingClientCombinedFormattingResponse{}, err } - return TextFormattingClientCombinedFormattingResponse{}, nil + return DocumentationTextFormattingClientCombinedFormattingResponse{}, nil } // combinedFormattingCreateRequest creates the CombinedFormatting request. -func (client *TextFormattingClient) combinedFormattingCreateRequest(ctx context.Context, _ *TextFormattingClientCombinedFormattingOptions) (*policy.Request, error) { +func (client *DocumentationTextFormattingClient) combinedFormattingCreateRequest(ctx context.Context, _ *DocumentationTextFormattingClientCombinedFormattingOptions) (*policy.Request, error) { urlPath := "/documentation/text-formatting/combined" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { @@ -97,31 +98,31 @@ func (client *TextFormattingClient) combinedFormattingCreateRequest(ctx context. // This is a sentence with *multiple italic* sections and *another italic* section. // *This entire sentence is italic.* // If the operation fails it returns an *azcore.ResponseError type. -// - options - TextFormattingClientItalicTextOptions contains the optional parameters for the TextFormattingClient.ItalicText +// - options - DocumentationTextFormattingClientItalicTextOptions contains the optional parameters for the DocumentationTextFormattingClient.ItalicText // method. -func (client *TextFormattingClient) ItalicText(ctx context.Context, options *TextFormattingClientItalicTextOptions) (TextFormattingClientItalicTextResponse, error) { +func (client *DocumentationTextFormattingClient) ItalicText(ctx context.Context, options *DocumentationTextFormattingClientItalicTextOptions) (DocumentationTextFormattingClientItalicTextResponse, error) { var err error - const operationName = "TextFormattingClient.ItalicText" + const operationName = "DocumentationTextFormattingClient.ItalicText" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.italicTextCreateRequest(ctx, options) if err != nil { - return TextFormattingClientItalicTextResponse{}, err + return DocumentationTextFormattingClientItalicTextResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TextFormattingClientItalicTextResponse{}, err + return DocumentationTextFormattingClientItalicTextResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return TextFormattingClientItalicTextResponse{}, err + return DocumentationTextFormattingClientItalicTextResponse{}, err } - return TextFormattingClientItalicTextResponse{}, nil + return DocumentationTextFormattingClientItalicTextResponse{}, nil } // italicTextCreateRequest creates the ItalicText request. -func (client *TextFormattingClient) italicTextCreateRequest(ctx context.Context, _ *TextFormattingClientItalicTextOptions) (*policy.Request, error) { +func (client *DocumentationTextFormattingClient) italicTextCreateRequest(ctx context.Context, _ *DocumentationTextFormattingClientItalicTextOptions) (*policy.Request, error) { urlPath := "/documentation/text-formatting/italic" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { diff --git a/packages/typespec-go/test/http-specs/documentation/zz_models.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_models.go similarity index 98% rename from packages/typespec-go/test/http-specs/documentation/zz_models.go rename to packages/typespec-go/test/http-specs/documentationgroup/zz_models.go index ee8385e594..0dee6934e6 100644 --- a/packages/typespec-go/test/http-specs/documentation/zz_models.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_models.go @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package documentation +package documentationgroup // BulletPointsModel - This tests: // - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points diff --git a/packages/typespec-go/test/http-specs/documentation/zz_models_serde.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_models_serde.go similarity index 98% rename from packages/typespec-go/test/http-specs/documentation/zz_models_serde.go rename to packages/typespec-go/test/http-specs/documentationgroup/zz_models_serde.go index ed2cb8569a..9fdee72651 100644 --- a/packages/typespec-go/test/http-specs/documentation/zz_models_serde.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_models_serde.go @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package documentation +package documentationgroup import ( "encoding/json" diff --git a/packages/typespec-go/test/http-specs/documentationgroup/zz_options.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_options.go new file mode 100644 index 0000000000..46580c6417 --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_options.go @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentationgroup + +// DocumentationListsClientBulletPointsModelOptions contains the optional parameters for the DocumentationListsClient.BulletPointsModel +// method. +type DocumentationListsClientBulletPointsModelOptions struct { + // placeholder for future optional parameters +} + +// DocumentationListsClientBulletPointsOpOptions contains the optional parameters for the DocumentationListsClient.BulletPointsOp +// method. +type DocumentationListsClientBulletPointsOpOptions struct { + // placeholder for future optional parameters +} + +// DocumentationListsClientNumberedOptions contains the optional parameters for the DocumentationListsClient.Numbered method. +type DocumentationListsClientNumberedOptions struct { + // placeholder for future optional parameters +} + +// DocumentationTextFormattingClientBoldTextOptions contains the optional parameters for the DocumentationTextFormattingClient.BoldText +// method. +type DocumentationTextFormattingClientBoldTextOptions struct { + // placeholder for future optional parameters +} + +// DocumentationTextFormattingClientCombinedFormattingOptions contains the optional parameters for the DocumentationTextFormattingClient.CombinedFormatting +// method. +type DocumentationTextFormattingClientCombinedFormattingOptions struct { + // placeholder for future optional parameters +} + +// DocumentationTextFormattingClientItalicTextOptions contains the optional parameters for the DocumentationTextFormattingClient.ItalicText +// method. +type DocumentationTextFormattingClientItalicTextOptions struct { + // placeholder for future optional parameters +} diff --git a/packages/typespec-go/test/http-specs/documentationgroup/zz_responses.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_responses.go new file mode 100644 index 0000000000..0d698a581a --- /dev/null +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_responses.go @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package documentationgroup + +// DocumentationListsClientBulletPointsModelResponse contains the response from method DocumentationListsClient.BulletPointsModel. +type DocumentationListsClientBulletPointsModelResponse struct { + // placeholder for future response values +} + +// DocumentationListsClientBulletPointsOpResponse contains the response from method DocumentationListsClient.BulletPointsOp. +type DocumentationListsClientBulletPointsOpResponse struct { + // placeholder for future response values +} + +// DocumentationListsClientNumberedResponse contains the response from method DocumentationListsClient.Numbered. +type DocumentationListsClientNumberedResponse struct { + // placeholder for future response values +} + +// DocumentationTextFormattingClientBoldTextResponse contains the response from method DocumentationTextFormattingClient.BoldText. +type DocumentationTextFormattingClientBoldTextResponse struct { + // placeholder for future response values +} + +// DocumentationTextFormattingClientCombinedFormattingResponse contains the response from method DocumentationTextFormattingClient.CombinedFormatting. +type DocumentationTextFormattingClientCombinedFormattingResponse struct { + // placeholder for future response values +} + +// DocumentationTextFormattingClientItalicTextResponse contains the response from method DocumentationTextFormattingClient.ItalicText. +type DocumentationTextFormattingClientItalicTextResponse struct { + // placeholder for future response values +} diff --git a/packages/typespec-go/test/http-specs/documentation/zz_version.go b/packages/typespec-go/test/http-specs/documentationgroup/zz_version.go similarity index 79% rename from packages/typespec-go/test/http-specs/documentation/zz_version.go rename to packages/typespec-go/test/http-specs/documentationgroup/zz_version.go index 92f4184e81..bf8a2484e8 100644 --- a/packages/typespec-go/test/http-specs/documentation/zz_version.go +++ b/packages/typespec-go/test/http-specs/documentationgroup/zz_version.go @@ -2,9 +2,9 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. -package documentation +package documentationgroup const ( - moduleName = "documentation" + moduleName = "documentationgroup" moduleVersion = "v0.1.0" )