mediatypes.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2020 Google LLC. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, softwis
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. package wellknown
  16. import (
  17. v3 "github.com/google/gnostic/openapiv3"
  18. )
  19. func NewGoogleApiHttpBodyMediaType() *v3.MediaTypes {
  20. return &v3.MediaTypes{
  21. AdditionalProperties: []*v3.NamedMediaType{
  22. {
  23. Name: "*/*",
  24. Value: &v3.MediaType{},
  25. },
  26. },
  27. }
  28. }
  29. func NewApplicationJsonMediaType(schema *v3.SchemaOrReference) *v3.MediaTypes {
  30. return &v3.MediaTypes{
  31. AdditionalProperties: []*v3.NamedMediaType{
  32. {
  33. Name: "application/json",
  34. Value: &v3.MediaType{
  35. Schema: schema,
  36. },
  37. },
  38. },
  39. }
  40. }
  41. func NewApplicationJsonMediaTypeByEmpty() *v3.MediaTypes {
  42. return &v3.MediaTypes{
  43. AdditionalProperties: []*v3.NamedMediaType{
  44. {
  45. Name: "application/json",
  46. Value: &v3.MediaType{},
  47. },
  48. },
  49. }
  50. }